import tarfile #压缩文件的方法 tar = tarfile.open('/tmp/demo.tar.gz','w:gz') #gzip压缩 tar.add('/etc/hosts') #添加要压缩的文件 tar.add('/etc/security') tar.close() #解压文件的方法 tar = tarfile.open('/tmp/demo.tar.gz','r:gz') tar.extractall() #解压文件到当前目录 tar.close()
python-tarfile模块(82)
最新推荐文章于 2024-04-27 00:07:16 发布