驗證碼識別是個大工程,但入門開始只要3步。需要用到的庫PIL、pytesserac,沒有的話pip安裝。還有一個是tesseract-ocr 下載地址:https://sourceforge.net/projects/tesseract-ocr-alt/files/。
哪3步?
1、安裝庫
pip install Pillow pip install pytesseract
2、安裝tesseract-ocr
默認安裝,主要是新添加個環境變量。如下圖
3、編寫代碼
import pytesseract from PIL import Image print pytesseract.image_to_string(Image.open("D:\\Desktop\\1.png"),lang="eng",config="-psm 7")
舉個例子,上圖的識別
bingo,7572!