一.普通文件读写方式 1.读取文件信息: with open('/path/to/file', 'r') as f: content = f.read() 2.写入文件中: with open('/Users/michael/test.txt', 'w') as f: f.write('Hello, world!') 注意: 1.如果是要读取二进制文件,比如图片.视频等等,用'rb'或'wb'模式打开文件: >>> f = open('/Users/michael/test.jpg',…
一:文件的多种读写方式 主方式:w r a 从方式:t b + 了解方式:x u 1)按t(按照字符进行操作): with open("data_1.txt","wt",encoding="utf-8") as f1: f1.write("你好,世界!") #with open......as用于代替close()完成对打开的文件的释放 with open("data_1.txt&qu…