import request
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
优美胜于丑陋
明了胜亍晦涩
简法胜于复杂
复杂胜于凌礼
扁平胜于嵌套
间隔胜亍紧凑

 

如果运行第一句时出错:python 错误: ModuleNotFoundError: No module named 'requests'

则需要进入cmd安装:pip3  install request

 

安装成功之后再运行