0
我在使用Pyunpack時遇到了一些麻煩。Python 7z Pyunpack TypeError
變量thing
是7z文件的路徑。
from pyunpack import Archive
Archive(thing).extractall(str(thing[0:thing.rfind('/')]))
此代碼旨在提取7z文件到其目錄。
在這種情況下,thing
是相對路徑: ./relative/path/my_7z_file.7z
這將返回一個模糊的類型錯誤:
Traceback (most recent call last):
File "importItAll.py", line 33, in <module>
Archive(thing).extractall(str(thing[0:thing.rfind('/')]))
File "/usr/local/lib/python2.7/dist-packages/pyunpack/__init__.py", line 74, in extractall
self.extractall_patool(directory, patool_path)
File "/usr/local/lib/python2.7/dist-packages/pyunpack/__init__.py", line 41, in extractall_patool
'--outdir=' + directory,
File "/usr/local/lib/python2.7/dist-packages/easyprocess/__init__.py", line 108, in __init__
self.cmd_as_string = ' '.join(self.cmd) # TODO: not perfect
TypeError: sequence item 1: expected string, NoneType found
我安裝了patool,現在我的代碼完美運行。謝謝! –