Created
June 22, 2020 09:45
-
-
Save shwangdev/4bd55081cda840de4add5a821bb4e741 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import zipfile | |
import sys | |
from pathlib import Path | |
def unzip(f, encoding, v): | |
with zipfile.ZipFile(f) as z: | |
for i in z.namelist(): | |
n = Path(i.encode('cp437').decode(encoding)) | |
if v: | |
print(n) | |
if i[-1] == '/': | |
if not n.exists(): | |
n.mkdir() | |
else: | |
with n.open('wb') as w: | |
w.write(z.read(i)) | |
if __name__ == '__main__': | |
for i in sys.argv[1:]: | |
unzip(i, 'cp932', 1) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment