Skip to content

Instantly share code, notes, and snippets.

@minaminao
Created December 15, 2017 03:45
Show Gist options
  • Save minaminao/0ed49d8d9323566070b14d1a7d7b9763 to your computer and use it in GitHub Desktop.
Save minaminao/0ed49d8d9323566070b14d1a7d7b9763 to your computer and use it in GitHub Desktop.
import zipfile
def encode():
UserEncodingFileName = input()
DirectoryName = input()
N = int(input())
files = []
for i in range(N):
line = input().split()
name = line[0]
files.append(name)
print(files)
with zipfile.ZipFile(UserEncodingFileName, 'w', zipfile.ZIP_DEFLATED) as zf:
for name in files:
zf.write(DirectoryName + '/' + name, name)
def decode():
UserEncodingFileName = input()
UnzipDirectoryName = input()
with zipfile.ZipFile(UserEncodingFileName, 'r') as zf:
zf.extractall(UnzipDirectoryName)
command = input()
if command == "encode":
encode()
else:
decode()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment