python解压TAR文件至指定文件夹的实例
如下所示:
######### Extract all files from src_dir to des_dir def extract_tar_files(src_dir,des_dir): files = os.listdir(src_dir) for file in files: dir_tmp = os.path.join(src_dir, file) print dir_tmp if not os.path.isdir(dir_tmp): ##是文件,非文件夹 #解压特定文件 if dir_tmp.endswith("gz") and (dir_tmp.find(cs.Port_week_perfer_name_start) != -1): #f = zipfile.ZipFile(dir_tmp, mode="r") f = tarfile.open(dir_tmp) names = f.getnames() for name in names: f.extract(name, path=des_dir) else: extract_tar_files(dir_tmp,des_dir) return 0
相关推荐
FlySky 2020-11-02
逍遥友 2020-10-26
taiyangshenniao 2020-10-05
flycony 2020-09-23
jacktangj 2020-09-18
YENCSDN 2020-09-15
lsjweiyi 2020-09-14
digwtx 2020-09-14
拾毅者 2020-09-14
zlxcsdn 2020-09-13
weiiron 2020-08-17
amazingbo 2020-08-16
郗瑞强 2020-08-16
lispython 2020-08-16
fengling 2020-08-15
xiesheng 2020-08-02
葫芦小金刚 2020-07-28
StevenSun空间 2020-07-26