Я хочу разделить zip-файл с помощью Python, а затем объединить разделенные файлы, я нашел этот код, но не могу объединить разделенные файлы - PullRequest
0 голосов
/ 01 ноября 2019

Спасибо @ Jeronimo

Разделить zip-архив на несколько кусков

outfile = archive_name
packet_size = int(1.5 * 1024**3)   # bytes

with open(outfile, "rb") as output:
    filecount = 0
    while True:
        data = output.read(packet_size)
        print(len(data))
        if not data:
            break   # we're done
        with open("{}{:03}".format(outfile, filecount), "wb") as packet:
            packet.write(data)
        filecount += 1

после разделения я не могу объединить их вместе

1 Ответ

0 голосов
/ 01 ноября 2019

К счастью, я сам решаю эту проблему

outfile = "archive_name"
packet_size = int(1024*1024*100)   # bytes
filenumbers=9   #number of files you want to join
for i in range(filenumbers):
    with open("{}.zip{:03}".format(outfile, i), "rb") as packet:
        col=packet.read(packet_size)

        with open("{}02.zip".format(outfile), "ab+") as mainpackage:
            mainpackage.write(col)

...