python 识别图片文字
当pip升级时报错
python -m pip uninstall pip setuptools
pip3 install --upgrade pip
c:\users\25671\appdata\local\programs\python\python38\python.exe -m pip install --upgrade pip
需要PIL 与 pytesseract库
识别中文的话需要Tesseract-OCR软件
import pytesseract
from PIL import Image
pytesseract.pytesseract.tesseract_cmd = 'E:/Program Files/Tesseract-OCR/tesseract'
image= Image.open('捕获56.PNG')
text = 9
text = pytesseract.image_to_string(image,lang='chi_sim')
list=[]
print(type(text))
for i in text.strip():
list.append(i)
print(list)
for i in list:
if i == '\n':
continue
else:
print(i,end='')
截图