Skip to content

Instantly share code, notes, and snippets.

@zhengxiaowai
Created November 15, 2016 12:24
Show Gist options
  • Save zhengxiaowai/7f961d2cf363f36d116c5559dc2ce818 to your computer and use it in GitHub Desktop.
Save zhengxiaowai/7f961d2cf363f36d116c5559dc2ce818 to your computer and use it in GitHub Desktop.
压缩一个文件夹,没有文件目录
def zip_dir(zipfile_path, zip_dir_path, file_tyle='*'):
with zipfile.ZipFile(zipfile_path, 'w') as z:
glob_file = glob.glob(os.path.join(zip_dir_path, file_tyle))
for filepath in glob_file:
z.write(filepath, os.path.basename(filepath))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment