1、文件的类型ide
2、打开模式指针
demo文件: file=open('b.txt','w') file.write('Python') file.close() 运行结果: 由于磁盘中没有b.txt文件,因此会生成新的文件——b.txt。同时在b.txt文件,内容为Python demo文件: file=open('b.txt','w') file.write('helloworld') file.close() 运行结果: b.txt文件已经存在,当再次运行demo文件,b.txt中的文件内容被替换,变为helloworld。