Code: Alles auswählen
#!/bin/python
import os
import tarfile
os.chdir("/home/x")
dw_bak = ['ild', 'rem.txt']
archive_name = "FooBar.tar"
tar = tarfile.open(archive_name, "w:bz2")
for content in [dw_bak]:
tar.add(content)
tar.close()
Es liegt daran, dass zwei Werte in der Variable dw_bak sind. Kann mir bitte jemand kurz sagen wie ich bei Dateien gleichzeitig in einer Variable deklarieren kann und dass sie aber auch archiviert werden.Traceback (most recent call last):
File "dokubak.py", line 10, in <module>
tar.add(content)
File "/usr/lib/python2.6/tarfile.py", line 1948, in add
if self.name is not None and os.path.abspath(name) == self.name:
File "/usr/lib/python2.6/posixpath.py", line 336, in abspath
if not isabs(path):
File "/usr/lib/python2.6/posixpath.py", line 52, in isabs
return s.startswith('/')
AttributeError: 'list' object has no attribute 'startswith'
Danke
P.