代码点读机 / Python / items

items Python · 字典方法

返回字典里所有键值对的视图。

怎么用

字典.items()

小例子

d = {'a': 1}
for k, v in d.items():
    print(k, v)

运行结果

a 1

官方文档:https://docs.python.org/zh-cn/3/library/stdtypes.html#typesmapping

在代码里遇到不认识的词?打开代码点读机,点一下就懂 → ← Python全部词条