Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我可以像这样使用 enumerate 和 python 字典:
for count, (key, value) in enumerate(my_dict.iteritems(), 1): print key, value, count
如何将 enumerate 与六库中的 iteritems 函数一起使用?
six.iteritems等价于,my_dict.iteritems()所以six.iteritems(my_dict):
six.iteritems
my_dict.iteritems()
six.iteritems(my_dict)
for count, (key, value) in enumerate(six.iteritems(my_dict), 1): print key, value, count