首页 > 编程语言 > 详细

3 Ways to Write Text to a File in Python

时间:2019-10-18 15:37:41      阅读:55      评论:0      收藏:0      [点我收藏+]

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)

 

3 Ways to Write Text to a File in Python

原文:https://www.cnblogs.com/andy-0212/p/11698444.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!