Fer*_*ker 0 python dictionary list
如果我在字典中有一系列列表(例如):
{'Name': ['Thomas', 'Steven', 'Pauly D'], 'Age': [30, 50, 29]}
Run Code Online (Sandbox Code Playgroud)
我想找到字符串的位置,这样我就可以从另一个列表中获得相同的位置.
所以,例如
if x = 'Thomas' #is in position 2:
y = dictionary['Age'][2]
Run Code Online (Sandbox Code Playgroud)
首先将其存放在适当的结构中.
D = dict(zip(dictionary['Name'], dictionary['Age']))
print D['Thomas']
Run Code Online (Sandbox Code Playgroud)