32
loading...
This website collects cookies to deliver better user experience
zipfile
.from zipfile import ZipFile
path_of_zip_file = input("Enter path of the zip file > ")
path_to_extract_to = input("Enter the path you want to extract to > ")
with ZipFile(path_of_zip_file , 'r') as files:
# here is where the codes are gonna go
extractall()
method.files.extractall(directory_to_extract_to)
read()
method of ZipFile
objects. The read()
method returns the bytes of the file name in the archive, so we are gonna take that and create the file with it. ZipFile.read(name, pwd=None)
method takes two parameters Name and Password. If you are working with encrypted file, don't forget to add your password. Now, we are going create a variable for our file name below the paths we declared on the common code snippet, but you can pass the file name directly too.
os
module, to write our file in the path we chose.file_name= os.path.join(directory_to_extract_to, file_to_extract)
with open(file_name, 'wb') as file:
file.write(files.read(file_name))
for file in files.namelist():
if file.endswith(".py"):
files.extract(file)
files.extractall(directory_to_extract_to, pwd=b'password')
Gooey module
, but I didn't want the post to be longer than it is. However, you can check the implementation in my Github. It is a very basic implementation, so read the documentation of gooey and you can add many features to it. If you like what you read, follow for more.