一、安裝Python依賴
pip install pytesseract pyocr pillow Image
pip安裝:https://www.cnblogs.com/Javame/p/10918325.html
二、下載並安裝 tesseract-ocr:
wget https://download.csdn.net/download/yiyu1/11200375
三、修改pytesseract.py
位置:..\lib\site-packages\pytesseract\pytesseract.py
tesseract.exe來源第二步安裝后Tesseract-OCR/tesseract.exe執行文件快捷方式。
四、找張圖片
五、Python代碼
from PIL import Image import pytesseract image = Image.open(r'E:\test.png') code = pytesseract.image_to_string(image) print(code)
六、執行腳本