pytesseract 显示“'str' 对象没有属性 'save'”错误
pytesseract shows " 'str' object has no attribute 'save' " error
当我运行下面的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)
当我运行下面的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)