#案例开发:将STU_PACK文件夹里的“万疆.TXT”和“Deam it possible.txt”合并到
#新的文件“万疆_DIP.txt”并保存到“demo”文件夹里。
fr_1=open(r'..\Stu_pack\file\万疆.txt','rt',encoding='utf-8')
fr_2=open(r'..\Stu_pack\file\Dream It Possible.txt','rt',encoding='utf-8')
fw=open(r'万疆_DIP.txt','a+',encoding='utf-8')
for line in fr_1:
fw.write(line)
for line in fr_2:
fw.write(line)
fw.seek(0)
for line in fw:
print(line)
fr_1.close()
fr_2.close()
fw.close()
两项txt文件相加
最新推荐文章于 2024-08-18 23:01:41 发布
![](https://img-home.csdnimg.cn/images/20240711042549.png)