‘‘‘
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
原文:https://www.cnblogs.com/xiazhenyu/p/13731739.html