python3 enumerate()函数笔记

d={"A":"a","B":"b","C":"c","D":"d"}

c=d.items()#字典(Dictionary) items() 函数以列表返回可遍历的(键, 值) 元组数组。
for a,b in c:
print(a,b)

b=enumerate(c)#对于一个可迭代的(iterable)/可遍历的对象(如列表、字符串),enumerate将其组成一个索引序列,利用它可以同时获得索引和值
print(b)
for k,j in b:
print(k,j)
for l in j:
print(l)
原文地址:https://www.cnblogs.com/lystbc/p/7489709.html