编写从 for 循环检索到的数据的最佳方法是什么?
L = ['abc','def','ghi']
for e in L:
with open ('outfile.txt','w') as outfile:
print (e, file=outfile)
##But the outfile.txt contains only:
##ghi
##
##
##I have to write all the elements:
##abc
##def
##ghi