Python items()---字典属性

背景知识点:

Python 字典(Dictionary) items() 函数以列表返回可遍历的(键, 值) 元组数组。

使用方法:

字典名.items()

示例:

dicts={'short':2,'int':4,'long':8,'long long':8}
for key,value in dicts.items():
    print(f'The size of {key} is {value} bytes.')

 

posted on 2022-03-10 09:45  进击的许盈盈  阅读(121)  评论(0编辑  收藏  举报