python zip压缩文件并设置密码

zip     -P "123" -r  app.zip         app
压缩文件 密码 压缩后名称 压缩对象名称

def zipDir(dirpath, outFullName, password=None):
    """
    压缩指定文件夹
    :param dirpath: 目标文件夹路径
    :param outFullName: 保存路径+xxxx.zip
    :return: 
    """
    import os
    if password:
        cmd = "zip -P %s -r %s %s" % (password, outFullName, dirpath)   有密码时设置密码并压缩
    else:
        cmd = "zip -r %s %s" % (outFullName, dirpath)   无密码直接压缩
    status = os.popen(cmd)
    执行系统命令
    return outFullName
DOCKERFILE



RUN apt-get update
RUN apt-get install zip

猜你喜欢

转载自www.cnblogs.com/lutt/p/11751825.html