#with open(文件路径,打开模式(rt/wt/at/rb/wb/ab),编码格式) as 变量名: # # 变量名.read/write with open('test.txt','r',encoding='utf8') as fr: data = fr.read() print(data) name='胡桃' print(name)# 胡桃 #会在文件后加上