有没有一种方法可以在一行Python代码中将一系列行追加到文件中? 我一直这样做:
lines = ['this is the foo bar line to append','this is the second line', 'whatever third line']
for l in lines:
print>>open(infile,'a'), l