我有一个Python字典,如:
Mydict = {'a':{'y':1,'x':5},'b':{'y':10,'x':8}}
有没有快速方法来访问与键对应的值:'x',在这种情况下是二级键,而不管第一级键?
我知道可以使用for循环来完成:
mylist=[] for k in Mydict.keys(): mylist.append(Mydict[k]['x'])
但它有什么快速的一线方法吗?
python dictionary
dictionary ×1
python ×1