1、下載相關組件
安裝:pip install Pillow 或下載:https://pypi.org/project/Pillow/5.2.0/ ,https://pypi.org/project/Pillow/5.2.0/#files,Pillow-5.2.0-cp36-cp36m-win_amd64.whl
下載后:在C:\Python36\Scripts目錄下:pip install Pillow-5.2.0-cp36-cp36m-win_amd64.whl
安裝:pip3 install pytesseract 或下載安裝:pytesseract-0.2.4.tar.gz 或 https://pypi.org/project/pytesseract/#files
下載:tesseract-ocr-w64-setup-v4.0.0-beta.1.20180608.exe 安裝,參見:圖片文字OCR識別-tesseract-ocr
2、實例程序
#coding:utf8 import os from PIL import Image import pytesseract file=r"D:\work\python36_crawl\pictureParser\中文.png" # file=r"D:\work\python36_crawl\pictureParser\英文.png" if os.path.exists(file): image = Image.open(file) # 英文 # vcode = pytesseract.image_to_string(image,"eng") vcode = pytesseract.image_to_string(image, "chi_sim") print(vcode)