-1
我有以下代碼:蟒蛇鹹菜轉儲tar文件
import cPickle as pickle
...
pickle.dump(wave, open(a_file, 'wb'), protocol=2)
工作正常。我想,所以我試圖做
pickle.dump(wave, tarfile.open(a_file, 'w:bz2'), protocol=2)
壓縮雖然使用BZ2文件,但我不斷收到此錯誤:
TypeError: argument must have 'write' attribute
不鹹菜只是不能正確識別的tar文件?我將如何執行一個pickle轉儲到tarfile?
我想,這是錯誤的原因'TarInfo.frombuf''從512字節字節對象構造一個TarInfo對象.' – Winand