您的代码不适用于Python3。原因是因为这样做
from pytesser import *(或只是首先将其导入)时,
if __name__ =='__main__'条件将为True,并且其下面的代码将运行。
如您所知,在Python 3中,
SyntaxError将出现在该行
print text。
我不确定为什么
SyntaxError在代码中看不到该错误,但是如果此错误以静默方式通过,则意味着首先没有导入任何内容,因此是该错误。
要解决此问题,请使用Python 2.7。
Python 2.7:
>>> from pytesser import *>>> print image_to_string<function image_to_string at 0x10057ec08>
Python 3:
>>> from pytesser import *Traceback (most recent call last): File "<stdin>", line 1, in <module> File "./pytesser.py", line 61 print text ^SyntaxError: invalid syntax
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)