Python高级编程-如何读写文本文件?

>>> f=open ('py3test.txt','wt',encoding='utf8')
>>> f.write('你好,我爱编程')
7
>>> f.close()
>>> f=open ('py3test.txt','rt',encoding='utf8')
>>> s=f.read()
>>> print(s)
你好,我爱编程
>>>

你可能感兴趣的:(Python高级编程)