[Python] overwriting file in ziparchive

Discussão em 'Python' iniciado por Stack, Novembro 22, 2024.

  1. Stack

    Stack Membro Participativo

    I have archive.zip with two files: hello.txt and world.txt

    I want to overwrite hello.txt file with new one with that code:

    import zipfile

    z = zipfile.ZipFile('archive.zip','a')
    z.write('hello.txt')
    z.close()


    but it won't overwrite file, somehow it creates another instance of hello.txt — take a look at winzip screenshot:

    [​IMG]

    Since there is no smth like zipfile.remove(), what's the best way to handle this problem?

    Continue reading...

Compartilhe esta Página