python读取txt文件,将多个空格转换成换行

with open(dirs+title[0]+".txt","w+",encoding='utf-8') as f:
       f.write('\r\n'.join(content))  

#'\r\n' 直接插入换行,解决换行问题 content中包含空格的全部内容

猜你喜欢

转载自blog.csdn.net/weixin_44683255/article/details/106214207