首页 > 编程语言 > 详细

python二进制读写文件

时间:2014-07-17 13:14:03      阅读:378      评论:0      收藏:0      [点我收藏+]
#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二进制读写文件

原文:http://www.cnblogs.com/kisstherain/p/3850442.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!