How To Move A Zip File To A New Destination And Then Open It In Python 3
How to move a zip file to a new destination and then open it in python 3. I have made following code, but it seems it does not work for zip file. import os source = 'C:/Users/sa/D
Solution 1:
This will move the zip from one location to another and then extract its contents to a directory of your choosing (other_dir
, in this instance)
import shutil
import zipfile
from contextlib import closing
def _unzip(archive, destination):
with closing(zipfile.ZipFile(archive, 'r')) as zip_file:
zip_file.extractall(destination)
SOURCE = "C:/Users/sa/Desktop/Pic_ - Im.zip"
DESTINATION = "C:/Users/sa/Pictures/pic"
shutil.move(SOURCE, DESTINATION)
_unzip(DESTINATION, other_dir)
Post a Comment for "How To Move A Zip File To A New Destination And Then Open It In Python 3"