首页 > 代码库 > python 分割文件、组合文件
python 分割文件、组合文件
import glob big_file = open(‘index.sql‘, ‘rb‘) bak_file = ‘index_bak‘ i = 1 while True: chunk = big_file.read(200000) if not chunk: break file_write = open(bak_file + str(i) + ‘.sql‘, ‘wb‘) file_write.write(chunk) file_write.close() i+=1 big_file.close() big_file = ‘index2.sql‘ file_merge = open(big_file, ‘wb‘) list_file = glob.glob("index_bak*") list_file = sorted(list_file, key=lambda d:d[len(bak_file)+1]) print(list_file) for spt_file in list_file: big_file = open(spt_file, ‘rb‘) file_merge.write(big_file.read()) big_file.close() file_merge.close()
python 分割文件、组合文件
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。