Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion Doc/library/tarfile.rst
Original file line number Diff line number Diff line change
Expand Up @@ -810,7 +810,7 @@ A ``TarInfo`` object has the following public data attributes:
.. attribute:: TarInfo.size
:type: int

Size in bytes.
Size of the archived file's data in bytes.


.. attribute:: TarInfo.mtime
Expand Down Expand Up @@ -1387,6 +1387,17 @@ a generator function instead of a list::
tar.extractall(members=py_files(tar))
tar.close()

How to read the content of a specific archive member into memory::

import tarfile

with tarfile.open("sample.tar.gz") as tar:
for member in tar:
f = tar.extractfile(member)
if f is not None:
content = f.read()
break

How to read a gzip compressed tar archive and display some member information::

import tarfile
Expand Down
Loading