2.文本文件的写入
- import fileinput
- file = open("D:\\test.txt", encoding="utf-8",mode="w")
- file.write("朝八晚十\n")
- file.close()
- with open("D:\\test.txt", encoding="utf-8",mode="a") as data:
- data.write("朝九晚五")
*mode="w",写模式,会重写文件;mode="a",追加模式,会在文件末尾添加数据。
2.文本文件的写入
*mode="w",写模式,会重写文件;mode="a",追加模式,会在文件末尾添加数据。
本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。