with open('1.txt','r',encoding = 'utf8')as f:
s = f.read() # 读取文本
# print(s) # 打印文本内容
with open(r'1.txt','r',encoding = 'utf8')as f:
r = f.read() # 逐一读取字符
with open(r'2.txt','w+',encoding = 'utf8')as f:
f.write(r) # 将读取内容写入新文本中
with open(r'1.txt','r',encoding = 'utf8')as f:
r = '\n'.join(f.read()) # 逐一读取字符并换行(将横排转竖排)
with open(r'3.txt','w+',encoding = 'utf8')as f:
f.write(r) # 将读取内容写入新文本中
希望能对大家有用。
本文地址:https://blog.csdn.net/t_123_y/article/details/107315567
如对本文有疑问, 点击进行留言回复!!
听课笔记--Python数据分析--Numpy基础及基本应用
Python-定时任务APScheduler中两种调度器的区别
网友评论