#coding=gbk ‘‘‘ Created on 2014-5-7 ‘‘‘ import os.path inputPath = ‘./input.txt‘ outPath = ‘./out.txt‘ bufferSize = 10 inputFile = open(inputPath, ‘rb‘) outFile = open(outPath, ‘wb+‘) fileSize = os.path.getsize(inputPath) readedSize = 0 while readedSize < fileSize - bufferSize : tmp = inputFile.read(bufferSize) outFile.write(tmp) readedSize = readedSize + bufferSize #读取剩下的部分 tmp = inputFile.read(fileSize % bufferSize) outFile.write(tmp) inputFile.close() outFile.close() print ‘done‘
相关文章
- 01-08Python库文件安装失败问题及解决方式汇总-持续更新ing~
- 01-08Python开发【笔记】:从海量文件的目录中获取文件名--方法性能对比
- 01-08python – 为什么从文件末尾搜索允许BZip2文件而不是Gzip文件?
- 01-08c – 从二进制文件读取结构数据时获取垃圾值
- 01-08python – 将bz2压缩二进制文件导入为numpy数组
- 01-08Python 读写excel数据
- 01-08day07 Python文件操作
- 01-08python解析文本文件演示样例
- 01-08使用PyInstaller将Python程序打包成一个单独的exe文件
- 01-08提升文件的读写效率--缓冲流