python 文字 识别

import requests
from aip import AipOcr

image = requests.get('https://static.pandateacher.com/7b5d6d8d9dea5691705d04fef2306b52.png').content

APP_ID = '11756541'
API_KEY = '2YhkLuyQGljPUYnmi1CFgxOP'
SECRET_KEY = '4rrHe2BF828bI8bQy6bLlx1MelXqa8Z7'

client = AipOcr(APP_ID, API_KEY, SECRET_KEY)
res = client.basicGeneral(image)
if 'words_result' in res.keys():
for item in res['words_result']:
print(item['words'])
else:
print(res)

结果:

bash:38$ python ~/classroom/apps-1-id-5c3d88f08939b4000100e7d3/38/main.py
优美胜于丑陋
明了胜亍晦涩
简法胜于复杂
复杂胜于凌礼
扁平胜于嵌套
间隔胜亍紧凑

猜你喜欢

转载自www.cnblogs.com/bzdmz/p/10323470.html