Python 3.7 如何将目录转换为ZIP?

Python 3.7 如何将目录转换为ZIP?,python-3.7,zipfile,Python 3.7,Zipfile,我想知道如何使用我使用的python 3.7将文件x直接转换为ZIP x.ZIP,并将其转换回普通文件 你也可以这样做 我用 你也可以这样做 对于无密码保护的压缩和解压缩: import threading from zipfile import ZipFile def ext(f, pw): try: f.extractall(pwd=pw) print('Cracked the .zip file') print('::::: %s

我想知道如何使用我使用的python 3.7将文件x直接转换为ZIP x.ZIP,并将其转换回普通文件

你也可以这样做

我用

你也可以这样做

对于无密码保护的压缩和解压缩:

import threading
from zipfile import ZipFile

def ext(f, pw):
    try:
        f.extractall(pwd=pw)
        print('Cracked the .zip file')
        print(':::::  %s' % pw)
    except:
        pass

f = 'file.zip'

pw = open('password.txt', 'r').readline()
for p in pw:
    crack=threading.Thread(target=ext, args=[f, p])
    crack.start()
要压缩文件,可以使用pyminizip模块

要解压缩文件,请使用Zipfile模块

对于受密码保护的压缩和解压缩:

import threading
from zipfile import ZipFile

def ext(f, pw):
    try:
        f.extractall(pwd=pw)
        print('Cracked the .zip file')
        print(':::::  %s' % pw)
    except:
        pass

f = 'file.zip'

pw = open('password.txt', 'r').readline()
for p in pw:
    crack=threading.Thread(target=ext, args=[f, p])
    crack.start()
对于ZIP:

import pyminizip
compression_level = 5 # 1-9
pyminizip.compress("/home/paulsteven/src.txt",'src', "dst.zip", "password", compression_level)
要解压缩:

from zipfile import ZipFile

with ZipFile('/home/paulsteven/dst.zip') as zf:
    zf.extractall(pwd=b'password')
对于无密码保护的压缩和解压缩:

import threading
from zipfile import ZipFile

def ext(f, pw):
    try:
        f.extractall(pwd=pw)
        print('Cracked the .zip file')
        print(':::::  %s' % pw)
    except:
        pass

f = 'file.zip'

pw = open('password.txt', 'r').readline()
for p in pw:
    crack=threading.Thread(target=ext, args=[f, p])
    crack.start()
要压缩文件,可以使用pyminizip模块

要解压缩文件,请使用Zipfile模块

对于受密码保护的压缩和解压缩:

import threading
from zipfile import ZipFile

def ext(f, pw):
    try:
        f.extractall(pwd=pw)
        print('Cracked the .zip file')
        print(':::::  %s' % pw)
    except:
        pass

f = 'file.zip'

pw = open('password.txt', 'r').readline()
for p in pw:
    crack=threading.Thread(target=ext, args=[f, p])
    crack.start()
对于ZIP:

import pyminizip
compression_level = 5 # 1-9
pyminizip.compress("/home/paulsteven/src.txt",'src', "dst.zip", "password", compression_level)
要解压缩:

from zipfile import ZipFile

with ZipFile('/home/paulsteven/dst.zip') as zf:
    zf.extractall(pwd=b'password')

要破解受保护的ZIP文件,请执行以下操作:

import threading
from zipfile import ZipFile

def ext(f, pw):
    try:
        f.extractall(pwd=pw)
        print('Cracked the .zip file')
        print(':::::  %s' % pw)
    except:
        pass

f = 'file.zip'

pw = open('password.txt', 'r').readline()
for p in pw:
    crack=threading.Thread(target=ext, args=[f, p])
    crack.start()

要破解受保护的ZIP文件,请执行以下操作:

import threading
from zipfile import ZipFile

def ext(f, pw):
    try:
        f.extractall(pwd=pw)
        print('Cracked the .zip file')
        print(':::::  %s' % pw)
    except:
        pass

f = 'file.zip'

pw = open('password.txt', 'r').readline()
for p in pw:
    crack=threading.Thread(target=ext, args=[f, p])
    crack.start()