# -*- coding:u8 -*- import tarfile def extract(tar_path, target_path): """ #tar_path为要解压文件 #target_path为解压存放目录 """ try: tar = tarfile.open(tar_path, "r:gz") file_names = tar.getnames() for file_name in file_names: tar.extract(file_name, target_path) tar.close() except Exception, e: raise Exception, e |
|
来自: 昵称23178714 > 《python脚本分享》