欢迎来到天天文库
浏览记录
ID:8826586
大小:56.05 KB
页数:2页
时间:2018-04-08
《基于python的名片识别接口调用代码实例》由会员上传分享,免费在线阅读,更多相关内容在应用文档-天天文库。
1、基于Python的名片识别接口调用代码实例代码描述:基于Python的名片识别接口调用代码实例#!/usr/bin/python#-*-coding:utf-8-*-importjson,urllibfromurllibimporturlencode #----------------------------------#名片识别调用示例代码-聚合数据#在线接口文档:http://www.juhe.cn/docs/139#---------------------------------- defmain(): #配
2、置您申请的APPKey appkey="*********************" #1.名片识别 request1(appkey,"POST") #名片识别defrequest1(appkey,m="GET"): url="http://op.juhe.cn/hanvon/bcard/query" params={ "image":"",#名片图像的base64串 "lang":"",#语言种类,简体:chns,繁体:chnt,英文:en,默认chns
3、 "color":"",#图像类型,gray:进行了灰度处理,original:原图,建议进行灰度处理 "key":appkey,#应用APPKEY(应用详细页查询) "dtype":"",#返回数据的格式,xml或json,默认json } params=urlencode(params) ifm=="GET": f=urllib.urlopen("%s?%s"%(url,params)) else: f=urllib.urlopen
4、(url,params) content=f.read() res=json.loads(content) ifres: error_code=res["error_code"] iferror_code==0: #成功请求 printres["result"] else: print"%s:%s"%(res["error_code"],res["reason"]) else:
5、print"requestapierror" if__name__=='__main__': main()
此文档下载收益归作者所有