Create zip archive with multiple files

后端 未结 1 815
小蘑菇
小蘑菇 2021-02-12 11:47

I\'m using following code where I pass .pdf file names with their paths to create zip file.

for f in lstFileNames:
        with zipfile.ZipFile(\'reportDir\' + s         


        
1条回答
  •  情话喂你
    2021-02-12 12:30

    Order is incorrect. You are creating new zipfile object for each item in lstFileNames

    Should be like this.

    with zipfile.ZipFile('reportDir' + str(uuid.uuid4()) + '.zip', 'w') as myzip:
        for f in lstFileNames:   
            myzip.write(f)
    

    0 讨论(0)
提交回复
热议问题