f.write
requires you to explicitly construct the string you want to write. print
is simpler.
with open('newfile.txt', 'w') as f:
for x, i in zip(a, b):
print(x, i, file=f)
You could use f.write(f'{x} {i}
')
instead of print
.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…