Python 读取、写入txt内容
with open("test.txt", "r") as f: # 打开文件
data = f.read() # 读取文件
print(data)
with open("test.txt","w") as f:
f.write("这是个测试!") # 自带文件关闭功能,不需要再写f.close()
标签:读取,Python,写入,test,txt,data
From: https://www.cnblogs.com/dewei233/p/16894256.html