Python的enumerate()返回索引和值的元组:
enumerate()
enumerate('abc') ((0,'a'),(1,'b'),(2,'c'))
我希望以item,index顺序(('a', 0))获得这些元组。
item,index
('a', 0)
我该怎么做呢?
我想使用反转元组来创建一个字典,如下所示:
{'a':0,'b':1,'c':2}
https://stackoverflow.com/questions/47841254
相似问题