3 Ways to Write Text to a File in Python

https://cmdlinetips.com/2012/09/three-ways-to-write-text-to-a-file-in-python/

1 with open("myOutFile.txt", "w") as outF:
2     for line in textList:
3         print(line, file=outF)
all_lines = ['1', '2', '3']
with open("myOutFile.txt", "w") as outF:
    outF.writelines(all_lines)
with open(out_filename, 'w') as out_file:
     .. 
     .. 
     .. parsed_line
     out_file.write(parsed_line)
原文地址:https://www.cnblogs.com/andy-0212/p/11698444.html