读取文件内容:
# 读取文件内容并按换行符切分 lines = open("data/voc01.txt", encoding="utf-8").read().split(" ")
写入文件:
# 追加写入到指定文件 str = "abcd" with open('E:/test/test_en.txt', mode='a+', encoding="utf-8") as w: w.write(str + " ")
读取文件内容:
# 读取文件内容并按换行符切分 lines = open("data/voc01.txt", encoding="utf-8").read().split(" ")
写入文件:
# 追加写入到指定文件 str = "abcd" with open('E:/test/test_en.txt', mode='a+', encoding="utf-8") as w: w.write(str + " ")