字典的遍历
主要内容包括key的遍历、value的遍历、以及键值对的遍历以及拆包
dict1 = {'name': 'tom', 'age': '20', 'gender': '男'}
for key in dict1.keys(): # 遍历字典的key
print(key)
print('------------------------') # 分割线
for value in dict1.values(): # 遍历字典的值
print(value)
print('------------------------') # 分割线
for item in dict1.items(): # 遍历键值对
print(item)
for key, value in dict1.items():#遍历键值对--拆包
print(f'{key}={value}')