【问题标题】:Zip all files in filepath压缩文件路径中的所有文件
【发布时间】:2017-01-15 00:14:01
【问题描述】:

我怎样才能使这个文件路径

zip.write (userhome+'\\thefolder\\')

压缩“thefolder”中的每个文件,例如如何在末尾添加各种通配符:

zip.write (userhome+'\\thefolder\\*')

【问题讨论】:

    标签: python python-2.7 file zip filepath


    【解决方案1】:

    shutil.make_archive 做到了:

    shutil.make_archive( base_name =  '/tmp/myBackup.zip',
                         format    =  'zip',
                         root_dir  =  userhome+'\\thefolder\\', 
                         base_dir  =  './' )
    

    【讨论】:

    • 如何添加更多要压缩的文件或目录?在 "root_dir = userhome+'\\thefolder\\',userhome+\\theotherfolder\\" 中的逗号后添加另一个不起作用。
    猜你喜欢
    • 2011-12-12
    • 1970-01-01
    • 1970-01-01
    • 2021-11-15
    • 1970-01-01
    • 2021-08-09
    • 2017-11-24
    • 2011-04-12
    • 2012-05-25
    相关资源
    最近更新 更多