读取文件内容:
# 读取文件内容并按换行符切分 lines = open("data/voc01.txt", encoding="utf-8").read().split("\n")
写入文件:
# 追加写入到指定文件 str = "abcd" with open(‘E:/test/test_en.txt‘, mode=‘a+‘, encoding="utf-8") as w: w.write(str + "\n")
原文地址:https://www.cnblogs.com/jumpkin1122/p/11516956.html
时间: 2024-11-06 03:44:12