Python 分割TXT文件成4K的TXT文件,python4k,[Python]代码#
Python 分割TXT文件成4K的TXT文件,python4k,[Python]代码#
[Python]代码
# # # 为了避免截断中文字符 # # 文件要求是 unicode 编码 # # txt文件另存为对话框下面有下拉框,可选存 # # 储编码格式 # # # ########################## import os import struct filename = str(raw_input("Please enter an old file name: ")) filenamepre = str(raw_input("Please enter an new file name prefix: ")) count = 0 filecount = 0 maxcount = 20 newfilename = repr(filecount) + '.txt' oldfile = open(filename,'rb') bFirst = True while True: s = oldfile.read(512*8 - 4) if not s: exit() filecount = filecount + 1 newfilename = filenamepre + repr(filecount).zfill(2) + '.txt' newfile = open(newfilename,'wb') if not bFirst: be = 0XFEFF newfile.write(struct.pack('H',be)) newfile.write(s) be = 0X000A000D newfile.write(struct.pack('I',be)) newfile.close() bFirst = False oldfile.close()
相关内容
- Python 最近最少使用算法,Python使用算法,[Python]代码#
- Python 最长公共子串算法,python串算法,[Python]代码#!
- Python 实现enum的功能,python实现enum,[Python]代码cl
- Python viterbi算法,pythonviterbi算法,[Python]代码de
- python 中文分词——FMM算法,,[Python]代码im
- Python 设置检查点简单实现,python检查,[Python]代码#
- Python 126邮箱自动登录程序,python126,[Python]代码im
- Python 将阿拉伯数字转换为罗马数字,python阿拉伯,[Pyt
- Python 将罗马数字转换成普通的阿拉伯数字,python阿拉伯
- Python 写入数据到MP3文件中,pythonmp3,[Python]代码wr
评论关闭