items() 方法的遍历:items() 方法把字典中每对 key 和 value 组成一个元组,并把这些元组放在列表中返回。

d = {'one': 1, 'two': 2, 'three': 3}
>>> d.items()
dict_items([('one', 1), ('two', 2), ('three', 3)])
>>> type(d.items())
<class 'dict_items'>

>>> for key,value in d.items():#当两个参数时
    print(key + ':' + str(value))
one:1
two:2
three:3

>>> for i in d.items():#当参数只有一个时
    print(i)
('one', 1)
('two', 2)
('three', 3)