1

当我为 pytesseract 运行以下代码时

>>> import pytesseract
>>> import Image
>>> print pytesseract.image_to_string("plate.png")

它显示以下错误

Traceback (most recent call last):
  File "<pyshell#5>", line 1, in <module>
    print pytesseract.image_to_string("plate.png")
  File "/usr/local/lib/python2.7/dist-packages/pytesseract/pytesseract.py", line 137, in image_to_string
    image.save(input_file_name)
AttributeError: 'str' object has no attribute 'save'

这个错误是什么意思?我该如何纠正这个?

提前致谢

4

1 回答 1

4

传递图像对象而不是文件路径(字符串):

import pytesseract
import Image

im = Image.open("plate.png")
print pytesseract.image_to_string(im)
于 2015-02-15T16:03:42.803 回答