无论如何,这一行,但没有列表理解
for x in someDict["place"]: # make this
for thing in x: # and this one line?
print(x[thing]["this_des1"])
print(x[thing]["that_des2"])
someDict = {
"place": [ { 0 : { "this_des1": 'data1', "that_des2" : 'data2' } },
{ 1 : { "this_ces1": 'data3', "that_ces2" : 'data4' } } ] }
由于您的dict有不同的键,而且似乎您正在尝试打印所有的底层值,因此使用
values()
比硬编码键更容易相关问题 更多 >
编程相关推荐