下面通过代码给大家介绍python打包压缩指定目录下的指定类型文件,具体代码如下所示:
import os
import datetime
import tarfile
import fnmatch
def find_spe_file(root, patterns=['*'], non_cludedir=[]):
for root, dirnames, filenames in os.walk(root):
for pattern in patterns:
for filename in filenames:
if fnmatch.fnmatch(fi
1