#!/usr/bin/python # encoding:utf-8 import urllib2, json, urllib, cookielib from poster.encode import multipart_encode from poster.streaminghttp import register_openers # 2、证件识别 data = {} data["appkey"] = "your_appkey_here" data["typeid"] = 2 register_openers() datagen, headers = multipart_encode({"pic": open("11.jpg", "rb")}) url_values = urllib.urlencode(data) url = "https://api.jisuapi.com/idcardrecognition/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]