Python tarfile: Difference between revisions
From wikinotes
(→append) |
(No difference)
|
Latest revision as of 21:59, 30 August 2016
read
import tarfile with tarfile.open( '/home/will/file.tar', 'r' ) as archive: contents = archive.getnames()
append
import tarfile with tarfile.open( '/home/will/file.tar', 'a' ) as archive: for filepath in newfiles: archive.add( filepath, arcname=os.path.basename(filepath) )