items()をつかって、forループでひとつずつ取り出す。
sample.py
dict={"A":1,"B":2,"C":3}fordict_str,dict_numindict.items():print(dict_str,dict_num,sep="→")# 出力結果
# A→1
# B→2
# C→3
中身を見てみるとリストの中にタプルが入っている。
sample.py
print(dict.items())# 出力結果
# dict_items([('A', 1), ('B', 2), ('C', 3)])
これらのタプルがアンパックされて
A → dict_str
1 → dict_num
へと入っていることが読み取れる。