python二进制读写文件

#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

python二进制读写文件,布布扣,bubuko.com

python二进制读写文件

上一篇:iOS开发多线程篇—NSOperation基本操作


下一篇:iOS开发多线程篇—创建线程