簡體   English   中英

用python字典中的六個庫枚舉

[英]enumerate with six library in python dictionary

我可以像這樣在python字典中使用枚舉:

for count, (key, value) in enumerate(my_dict.iteritems(), 1):
    print key, value, count

如何在六個庫中的iteritems函數中使用枚舉?

my_dict.iteritems()six.iteritems等效為six.iteritems(my_dict) ,因此:

for count, (key, value) in enumerate(six.iteritems(my_dict), 1):
    print key, value, count

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM