根据正则表达式选择性解压文件
from zipfile import ZipFile
import re def is_match(expression, filename):
pattern = re.compile(expression)
match = pattern.match(filename)
return match def decompression(zipFileName, expression, filePath):
zip_file = ZipFile(zipFileName)
file_list = zip_file.namelist()
for name in file_list:
if is_match(expression, name):
print(name)
zip_file.extract(name, filePath) if __name__ == '__main__':
decompression(r"E:\Temp\20130816.zip", ".*DST.*", r"E:\Temp\22")