不同缓冲区读写文件的效率比较 环境:CentOS6.3/ext3/ 读取文件大小:100000000B BUFSIZE TIMECOST 1 real 0m38.909s user 0m5.960s sys 0m32.888s 2 real 0m20.015s user 0m2.927s sys 0m17.063s 4 real 0m11.065s user 0m1.551s sys 0m9.491s 8 real 0m5.160s user 0m0.766s sys 0m4.390s 16 r…
一.普通文件读写方式 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',…