python文件打开wr_Python文件和流(实例讲解)
Python文件和流(实例讲解)1.文件写入#打开文件,路径不对会报错f = open(r"C:\Users\jm\Desktop\pyfile.txt","w")f.write("Hello,world!\n")f.close()2.文件读取#读取f = open(r"C:\Users\jm\Desktop\pyfile.txt","r")print(f.read())f.close()输出:H