2015-09-20 41 views
1

試圖將PDF解析爲文本並試圖從Slate開始。Python中的板岩在山腳上磕磕碰碰

然而,只是跟着到處張貼的簡單的例子,我得到如下:

>>> import slate 
>>> with open('pytest.PDF') as fp: 
...  doc = slate.PDF(fp) 
... 
Traceback (most recent call last): 
    File "<stdin>", line 2, in <module> 
    File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/slate/slate.py", line 52, in __init__ 
self.append(self.interpreter.process_page(page)) 
    File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/slate/slate.py", line 36, in process_page 
self.device.outfp.buf = '' 
AttributeError: 'cStringIO.StringO' object has no attribute 'buf' 

任何想法?

回答

0

這可以通過改變線36被固定發生的位置誤差爲:

self.device.outfp.truncate(0)