python中items()函数

 
 
  1. items() 函数以列表返回可遍历的(键, 值) 元组。

  2. 将字典中的键值对以元组存储,并将众多元组存在列表中。

  3. 如:

scores = {'甘露':23,'jock':18,'qiao':22,'谷雨':24,'嘟嘟':6}
item = scores.items()
print(item)
dict_items([('甘露', 23), ('jock', 18), ('qiao', 22), ('谷雨', 24), ('嘟嘟', 6)])

把字典拆分为元组储存到列表中

猜你喜欢

转载自blog.csdn.net/Feixiangdechenyu/article/details/133068392
今日推荐