写文件
with open('test.txt','w') as file_object:
file_object.write('Hello Python!')
追加文件
with open('test.txt','a') as file_object:
file_object.write('Hello Python again!')
读文件
with open('test.txt') as file_object:
content = file_object.read()
print(content)
输出
Hello Python!Hello Python again!