首页 银行卡识别 银行卡识别示例代码 银行卡识别[Python]

银行卡识别示例代码[Python]

作者:liuxiaojie 阅读数:1240 上传时间:2016-03-10

银行卡识别

#!/usr/bin/python
# encoding:utf-8

import urllib2, json, urllib
from poster.encode import multipart_encode
from poster.streaminghttp import register_openers



# 1、银行卡识别

data = {}
data["appkey"] = "your_appkey_here"
register_openers()
datagen, headers = multipart_encode({"pic": open("11.jpg", "rb")})

url_values = urllib.urlencode(data)
url = "http://api.binstd.com/bankcardcognition/recognize" + "?" + url_values

request = urllib2.Request(url,datagen, headers)
result = urllib2.urlopen(request)
jsonarr = json.loads(result.read())
if jsonarr["status"] != u"0":
    print jsonarr["msg"]
    exit()
result = jsonarr["result"]

for v in result:
    print v,result[v]