You can download this code by clicking the button below.
This code is now available for download.
Create a zipfile, add a specified file to the zipfile, and extract it to a specified directory.
Technology Stack : zipfile
Code Type : File operation
Code Difficulty : Intermediate
def zipfile_create_extract(filename, mode='w'):
import zipfile
with zipfile.ZipFile(filename, mode) as z:
z.write('example.txt', 'example.txt')
z.extractall('extracted_files')