-
archive file
An archive file is a file that is composed of one or more computer files along with metadata.
Archive files are used to collect multiple data files together into a single file for easier portability and storage, or simply to compress files to use less storage space.
-
tar
In computing, tar is a computer software utility for collecting many files into one archive file, often referred to as a tarball, fordistribution or backup purposes.
-
gzip
www.gzip.org
gzip is a file format and a software application used for file compression and decompression.
gzip is based on the DEFLATE algorithm, which is a combuination of LZ&& and Huffman coding.
-
tar.gz
Tar files are often compressed after being created, giving it the
.tar.gz
file extension.Technically these are
TGZ
files, but nearly everyone calls both.tar
and.tar.gz
files simple “tar files
”. -
open a tar file
tar -xzf tarfile # extract tar -czf tar.tar.gz tar # create
-v
enables verbose mode, showing the progress of the commna-x
extract-c
create-z
usesgzip
, omit this if you hust have a.tar
-f
specifies file input, rather thanSTDIN
-
through python
The tarfile module makes it possible to read and write tar archives, including those using gzip, bz2 and lzma compression.
tarfile.ooen(name=None, mode='r', fileobj=None, bufsize=10240,**kwargs)
return aTarFile
object for the pathnamename
.TarFile = tarfile.open('path/file.tar.gz','r:gz') tf.list(verbose=False) # 查看文件内容 tf.getnames() # 返回list,包内文件名 tf.getmember(name) # 返回member tf.extract(member) # 提取文件 tf.extractall() # 提取全部文件
-
下载tar.gz文件
import requests r = request.get(url) with open(filepath, 'wb') as f: f.write(r.content)
python从url下载并打开tar.gz文件
最新推荐文章于 2024-01-02 20:58:07 发布