items()方法:
# 定义一个字典
test_dict = dict(
name='zs',
age=18)
for key, value in test_dict.items():
print(key, value)
# 结果为
name zs
age 18
keys()方法:
test_dict = dict(
name='zs',
age=18)
print(test_dict.keys())
# 结果为
['name', 'age']
values()方法:
test_dict = dict(
name='zs',
age=18)
print(test_dict.values())
# 结果为
['zs', 18]