已知字典中某几个key,取每个key对应的值

'''
https://www.cnblogs.com/xiazhenyu/
'''

dict1={
"attr":{
"httpClient":{
"hasData":"false",
"cacheKey":"8888rrr"
}
}
}

# print(dict1['attr']['httpClient']['cacheKey'])

a="attr,httpClient,cacheKey"
res=a.split(',')
# print(res[0])
# print(dict1[res[0]][res[1]][res[2]])

nums=2
if nums == 0:
print(dict1[res[0]])
elif nums == 1:
print(dict1[res[0]][res[1]])
elif nums == 2:
print(dict1[res[0]][res[1]][res[2]])

#返回结果:8888rrr

上一篇:记录电子竞技游戏jesp中的传输过程公式


下一篇:字典排序