疊代字典使用方式-讀取dict-key、value值
- 讀取dict-key、value值
- 讀取key值
- 讀取value值
讀取dict-key、value值
the_dict = {'a': 'aa', 'b': 'bb', 'd': 'dd', 'e': 'ee'}
#疊代字典的key值和value值
for key,value in the_dict.items():
print(key)
print(value)
讀取key值
讀取value值
the_dict = {'a': 'aa', 'b': 'bb', 'd': 'dd', 'e': 'ee'}
#疊代字典的key值
for key1 in the_dict.keys():
print(key1)
#疊代字典的value值
for value1 in the_dict.values():
print(value1)
Yiru@Studio - 關於我 - 意如