Pytesseract显示" 'str' object has no attribute 'save' "错误



当我为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'

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

提前感谢

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

import pytesseract
import Image
im = Image.open("plate.png")
print pytesseract.image_to_string(im)

最新更新