【问题标题】:Slate in Python stumbles on foothillsPython 中的 Slate 在山脚下绊倒
【发布时间】:2015-09-20 01:04:00
【问题描述】:

正在尝试将 PDF 解析为文本,并一直尝试从 Slate 开始。

但是,只要遵循随处发布的基本示例,我就会得到以下信息:

>>> 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'

有什么想法吗?

【问题讨论】:

    标签: python slate


    【解决方案1】:

    这可以通过将发生错误的第 36 行更改为读取来解决:

    self.device.outfp.truncate(0)
    

    【讨论】:

      猜你喜欢
      • 2011-01-31
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-06-30
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多