my_dict = {'a': 0, 'b': 1, 'c': 2}
# python 3.x
print (list(my_dict.keys()).index('c'))
# python 2.7
print (my_dict.keys().index('c'))
return the index of a 'key' in Python dictionary
最新推荐文章于 2022-04-18 10:54:35 发布
my_dict = {'a': 0, 'b': 1, 'c': 2}
# python 3.x
print (list(my_dict.keys()).index('c'))
# python 2.7
print (my_dict.keys().index('c'))