python list转字典
>>> lst = ['A','B','C']
>>> dict(zip(lst,range(len(lst))))
>>> lst = ['A', 'B', 'C']
>>> dict(map(reversed, enumerate(lst)))
>>> {'A': 0, 'C': 2, 'B': 1}
如果取索引,这样就可以:
a=[72, 56, 76, 84, 80, 88]
print(a.index(76))
python list转字典
>>> lst = ['A','B','C']
>>> dict(zip(lst,range(len(lst))))
>>> lst = ['A', 'B', 'C']
>>> dict(map(reversed, enumerate(lst)))
>>> {'A': 0, 'C': 2, 'B': 1}
如果取索引,这样就可以:
a=[72, 56, 76, 84, 80, 88]
print(a.index(76))