python中文件读取的方法
python中文件读取的方法: 一般用with执行对文件的操作比较方便,可以省去关闭文件的代码(老忘记)。用with写入txt文件操作:with open('data.txt', 'w') as f: f.write('hello world') # 这样就可以将hellow world写入到data.txt文件中1.open()函数 python open() 函数用于打开一个文件,创建一个 file 对象,相关的方法才可以调用它进行读写。open(name[, mode[,
原创
2021-04-30 10:36:50 ·
14245 阅读 ·
0 评论