tar解压指定文件
作者:互联网
import tarfile
import sys
#tar = tarfile.open('/opt/platform-omp/omp.tar.gz','r')
tar = tarfile.open(r'C:\Users\Administrator\Desktop\omp.tar.gz','r')
path=''
# 获取包内的所有文件列表
for i in tar.getnames():
if 'kara_create.sql' in i:
path=i
break
print (path)
if path:
member=tar.getmember(path)
res=tar.extract(member, path=r"C:\Users\Administrator\Desktop")
print (res)
else:
print ('未找到文件')
sys.exit(1)
# insert into config_param (`key`, `value`, `defined_value`, `description`, `need_reboot`) values ('captcha.enabled', 'true', 'true', '{"en_US":"Whether to open the verifying code","zh_CN":"是否开启验证码"}', 'false');
标签:解压,tar,指定,gz,omp,path,Desktop,open 来源: https://www.cnblogs.com/slqt/p/10760572.html