output_path = 'out.txt'
with open(output_path, 'w', encoding='utf-8') as f:
dict1={"1":"An",
"2":"Gn"
}
list1=[
"1",
"2",
"3",
]
for i in list1:
print(dict1.get(i),file=f
运行结果:
output_path = 'out.txt'
with open(output_path, 'w', encoding='utf-8') as f:
dict1={"1":"An",
"2":"Gn"
}
list1=[
"1",
"2",
"3",
]
for i in list1:
print(dict1.get(i),file=f
运行结果: