Python读写文件

38 阅读1分钟

写入

with open('example.txt', 'w') as file:
    for i in text:
        file.write(i)

读取

with open('example.txt', 'r') as file:
    content = file.read()
    print(content)