Python实现face++银行卡识别

    看博客时看到别人写了face++的身份证识别,打开face++官网看了下,正好在学些Python,也动手写了银行卡识别的代码,在编写时,遇到了image_file上传的问题,觉得face++给的例子有点繁琐,自己使用requests写了下,返回OK!

代码如下:

import requests

httpurl = 'https://api-cn.faceplusplus.com/cardpp/v1/ocrbankcard'
file_path = r'f:\1.jpg'
apikey ='********' #官网api_key
apisecret = '*******' #官网api_secret

f= open(file_path, "rb")
data = {
   'api_key':apikey,
   'api_secret':apisecret
}
image_file = {'image_file':open(file_path,'rb')}
response = requests.post(httpurl,data = data,files=image_file)
print(response.json())

你可能感兴趣的:(Python)