本章教程利用python实现查询银行卡号名称和简称 。
目录
一、 实例代码
二、运行效果
一、 实例代码
#!/usr/bin/python
# -*- coding: UTF-8 -*-
"""
@author: Roc-xb
@desc: python 实现银行卡号查询银行简称
"""
import requestsdef bank_mes(bank_no):try:url = "https://ccdcapi.alipay.com/validateAndCacheCardInfo.json?_input_charset=utf-8&cardNo={}&cardBinCheck=true"data = requests.get(url.format(bank_no)).json()bank_abbr = data['bank']bank_map = {"ICBC": "中国工商银行","ABC": "中国农业银行","CCB": "中国建设银行","CMB": "招商银行","BOC": "中国银行","PSBC": "中国邮政储蓄银行","COMM": "交通银行","CITIC": "中信银行","CMBC": "中国民生银行","CEB": "中国光大银行","CIB": "兴业银行","SPDB": "浦发银行","GDB": "广发银行","SPABANK": "平安银行","HXBANK": "华夏银行","BJBANK": "北京银行","SHBANK": "上海银行","JSBANK": "江苏银行","BJRCB": "北京农商银行","JSRCU": "江苏省农村信用社联合社","BOYK": "营口银行","WOORI": "友利银行","DZLCYRCZYH": "陵城圆融村镇银行","BXBANK": "本溪市商业银行","WHBANK": "乌海银行","AXDSCB": "安新大商村镇银行","RQCZYH": "任丘村镇银行","JXRCU": "江西省农村信用社","JKRFCZYH": "长春经开融丰村镇银行","BOHN": "海南省农村信用社","CRCBANK": "重庆农村商业银行","ASCB": "鞍山银行","LLVB": "兰陵村镇银行","UBCHN": "海口联合农商银行","BSB": "蒙商银行","MMDBCJCZYH": "天水秦州长银村镇银行","CSRCB": "常熟农商银行","NJMSCZYH": "固始天骄村镇银行","IELZSXHDCZYH": "稷山县河东村镇银行","FSVB": "丰南舜丰村镇银行","JSB": "晋商银行","HURCB": "湖北省农信社","ZGCBANK": "北京中关村银行","EGBANK": "恒丰银行","SQZYFDCZYH": "贵阳花溪建设村镇银行","YJSHCB": "永济市三禾村镇银行有限责任公司","GXYHGMCZYH": "长春二道农商村镇银行","SDLJB": "山东利津舜丰村镇银行","LSBANK": "莱商银行","JHBANK": "金华银行","LSBC": "临商银行","YZBANK": "银座村镇银行","XMBANK": "厦门银行","XNZJCZYH": "深圳龙岗鼎业村镇银行","JXYMYH": "江西裕民银行股份有限公司","DBSHMCZYH": "调兵山惠民村镇银行","DRCBCL": "东莞农村商业银行","RBOZ": "珠海华润银行","PZHCCB": "四川银行","GDRCC": "广东省农村信用社联合社","HANABANK": "韩亚银行","TLSHCB": "屯留三禾村镇银行","MTBANK": "浙江民泰商业银行","LANGFB": "廊坊银行","BOJZ": "锦州银行","TJBHB": "天津滨海农村商业银行","LLBJSJJRFCZYH": "东丰吉银村镇银行","HSBANK": "徽商银行","NNJNGMCZYH": "南宁江南国民村镇银行","NXRCU": "宁夏黄河农村商业银行","FXLZCB": "费县梁邹村镇银行","QLBANK": "齐鲁银行","WRCB": "无锡农村商业银行","CGXYYH": "长葛轩辕村镇银行","IBK": "企业银行","BANKWF": "潍坊银行","CZBANK": "浙商银行","LQRB": "临朐村镇银行","ZYTYCZYH": "宁夏西吉汇发村镇银行","HRXJB": "湖南银行","YBF": "豫丰村镇银行","JZCBANK": "焦作中旅银行","TLXXCZYH": "铁岭新星村镇银行","SDSHHJCZYH": "山东商河汇金村镇银行","WCYRCZYH": "武城圆融村镇银行","HKBEA": "东亚银行","GZRCU": "贵州省农村信用社联合社","LPSZSLDCZYH": "六盘水钟山凉都村镇银行","RHMYCZYH": "仁怀蒙银村镇银行","ZZYH": "枣庄银行","HYXHNSCZYH": "宁夏永宁汇发村镇银行","LLYRCZYH": "乐陵圆融村镇银行","ZRCBANK": "张家港农村商业银行","QHJRCB": "清河金农村镇银行","WYYCCZYH": "舞阳玉川村镇银行","DCSFCZYH": "大城舜丰村镇银行","QDCCB": "青岛银行","HDCB": "黔西花都村镇银行","ARCU": "安徽省农村信用社","SDLCYRCZYH": "历城圆融村镇银行","QLXACZYH": "隰县新田村镇银行","ZGCCB": "自贡银行","ALEJHCB": "阿拉尔津汇村镇银行","BOHAIB": "渤海银行","SDEB": "顺德农商银行","HBC": "湖北银行","LYCB": "辽阳银行","FXCB": "阜新银行","PSATCZYH": "盘山安泰村镇银行","WJRCB": "苏州农村商业银行","SDZFQFCZYH": "山东芝罘齐丰村镇银行","HBFNJXCZYH": "乳山天骄村镇银行","HSB": "恒生银行","NYBANK": "广东南粤银行","BGB": "广西北部湾银行","DAQINGB": "龙江银行","CDCB": "成都银行","DZCBANK": "达州市商业银行","HLDB": "葫芦岛银行","ZZZYFDCZYH": "平遥县晋融村镇银行","ZYBZHLCZYH": "遵义播州汇隆村镇银行","HEBXFCZYH": "平舆玉川村镇银行","WZCB": "温州银行","ZJSYHTCZYH": "浙江松阳恒通村镇银行","H3CB": "内蒙古银行","GRCB": "广州农村商业银行","HSBC": "汇丰银行(中国)","QHRC": "青海省农村信用社","LSCCB": "乐山市商业银行","SZSBK": "石嘴山银行","SINO": "永丰银行","CCQTGB": "重庆三峡银行","HSBK": "衡水市商业银行","NJXLRB": "内江村镇银行","GYGSB": "广元贵商村镇银行","SXBANK": "三湘银行","CJYMCZYH": "沙河襄通村镇银行","WAHDCZYH": "平阴蓝海村镇银行","DLB": "大连银行","BHB": "河北银行","LYJDCZYH": "莱阳胶东村镇银行","AMBZJDYFMCZYH": "包头市昆都仑蒙银村镇银行","SXQNRCB": "陕西秦农农村商业银行股份有限公司","YQCCB": "阳泉市商业银行","XTB": "邢台银行","SJBANK": "盛京银行","DYCCB": "东营银行","SDZHQYCZYH": "山东沾化青云村镇银行","BDCBANK": "保定银行","DZBANK": "德州银行","ANTBANK": "网商银行","ZJNX": "浙江农商联合银行","PZBANK": "盘锦银行","CSCB": "长沙银行","PBDLCZYH": "平坝鼎立村镇银行","ZQQLCZYH": "天镇县河东村镇银行","HZCB": "杭州银行","JZBANK": "晋中银行","BOCFCB": "中银富登村镇银行","RCXNSCZYH": "石阡长征村镇银行","SRCB": "深圳农村商业银行","QHSRB": "黄岛舜丰村镇银行","YACCB": "雅安市商业银行","ZYB": "中原银行","SDRCU": "山东省农村信用社联合社","BOHUIHE": "新疆汇和银行","QLCZYH": "青隆村镇银行","GCB": "广州银行","SXRCCU": "陕西省农信社","XJRCU": "新疆农村信用社","JLBANK": "吉林银行","TACCB": "泰安银行","GYCB": "贵阳银行","GSBANK": "甘肃银行","SDLZHJCZYH": "山东临淄汇金村镇银行","LSYH": "辽沈银行","XHCZYH": "新华村镇银行","HHRXCZYH": "兰西农商村镇银行","NXTXJHCB": "宁夏同心津汇村镇银行","NBIZJZSCZCZYH": "松桃长征村镇银行","RZB": "日照银行","DHDYCZYH": "德惠敦银村镇银行","KLB": "昆仑银行","XZBANK": "西藏银行","JJBANK": "九江银行","SXRCU": "山西省农村信用社","HNBANK": "海南银行股份有限公司","DJCZCZYH": "德江长征村镇银行","CGNB": "四川天府银行","WHFMCZYH": "威海富民村镇银行","CZCB": "浙江稠州商业银行","WZMSBANK": "温州民商银行","ETKQHZCB": "鄂托克旗汇泽村镇银行股份有限公司","QWXXTCZYH": "阜平大商村镇银行","SHRCB": "上海农商银行","SNCCB": "遂宁银行","TLBANK": "铁岭银行","NDHB": "宁波东海银行","NXBANK": "宁夏银行","NMGNXS": "内蒙古农村信用社联合社","SNBANK": "苏宁银行","ZQZSGYCZYH": "虞城通商村镇银行","DBSCN": "星展银行","HBRCU": "河北省农村信用社","LXHRCZYH": "岚县慧融村镇银行","GYBYDXCZYH": "贵阳白云德信村镇银行","LNRCC": "辽宁农商银行","DYLSCB": "东营莱商村镇银行","TCCB": "天津银行","BOQZ": "泉州银行","NBBANK": "宁波银行","WHRCB": "武汉农村商业银行","ZYYCCZYH": "正阳玉川村镇银行","NCB": "江西银行","ZJKCCB": "张家口银行","JNBANK": "济宁银行","KELFMCZ": "库尔勒富民村镇银行","XCXPCZYH": "许昌新浦村镇银行","EEDSSHTCZYH": "鄂尔多斯市罕台村镇银行","KLLACB": "垦利乐安村镇银行","HRBANK": "哈尔滨银行","BOQH": "青海银行","YBCCB": "宜宾市商业银行","NJNKCZYH": "南江农科村镇银行","LTSFRB": "乐亭村镇银行","LZYH": "兰州银行","NJCB": "南京银行","JINCHB": "晋城银行","TZCB": "台州银行","CQBANK": "重庆银行","SXBA": "山西银行","PYYRCZYH": "平原圆融村镇银行","URB": "联合村镇银行","FDB": "富滇银行","LYRTCZYH": "长春绿园融泰村镇银行","SCRCU": "四川省农村信用社联合社","AHXABANK": "安徽新安银行","GAXQB": "贵安新区发展村镇银行","YTBANK": "烟台银行","DLRCB": "大连农村商业银行","PCNKCZYH": "平昌农科村镇银行","QYLACZYH": "庆云乐安村镇银行","NYCB": "南阳村镇银行","ASXHNMCZYH": "安顺西航南马村镇银行","BTSDHJGCZYH": "江口长征村镇银行","QHDBANK": "秦皇岛银行","SDHMB": "山东惠民舜丰村镇银行","NBCBANK": "宁波通商银行","JXRJGDCB": "江西瑞金光大村镇银行","SRBANK": "上饶银行","BJCPBSCZYH": "哈尔滨阿城农商村镇银行","HNRCU": "河南省农村信用社","RXBANK": "瑞信村镇银行","HNSSXNSCZYH": "山东金乡蓝海村镇银行","MZKSB": "梅州客商银行","SHZGMCZYH": "平陆县河东村镇银行","BOSZ": "苏州银行","YXCCB": "云南红塔银行","SCMYCZYH": "水城蒙银村镇银行","XIB": "厦门国际银行","BOCD": "承德银行","HUAMINGBANK": "华明村镇银行","YYBSCB": "博商银行","HNRCC": "湖南省农村信用社","XABANK": "西安银行","TRCB": "天津农商银行","BOSH": "新韩银行","GHB": "广东华兴银行","CCHRCZYH": "长春朝阳和润村镇银行","CZRCB": "江南农村商业银行","URMQCCB": "乌鲁木齐银行","MYBANK": "绵阳市商业银行","HDBANK": "邯郸银行","JRCB": "江苏江阴农村商业银行","CITICN": "花旗银行(中国)","KJCZYH": "梅县客家村镇银行","ZJQZQJSYCZYH": "衢江上银村镇银行","HLJRCU": "黑龙江省农村信用社联合社","XJB": "新疆银行","KCBEBANK": "天津金城银行","DYCB": "长城华西银行","QAXLCB": "迁安襄隆村镇银行","BOD": "东莞银行","NCBANK": "南洋商业银行","WHCCB": "威海市商业银行","BOCZ": "沧州银行","BOCY": "朝阳银行","CABANK": "长安银行","BOL": "中原银行洛阳分行","HKB": "汉口银行","WSQBSCZYH": "江苏江都吉银村镇银行","BOP": "平顶山银行","GXRCU": "广西壮族自治区农村信用社联合社","SXCB": "绍兴银行","YJHLLLCZYH": "神池县河东村镇银行","PTFMCZYH": "都匀融通村镇银行","HNCMCJCZYH": "夏县河东村镇银行","YKYHCCB": "营口沿海银行","FJNX": "福建省农村信用社联合社","ZBCB": "齐商银行","GZB": "赣州银行","HZCCB": "湖州银行","GXPNGYCZYH": "浙江文成北银村镇银行","QJCCB": "曲靖市商业银行","ZJLXYSCZYH": "浙江兰溪越商村镇银行","ZXBXBANK": "百信银行","JXBANK": "嘉兴银行","WACZYH": "武安村镇银行","KSRB": "昆山农村商业银行","FJHXBC": "福建海峡银行","BDXHRCZYH": "保德县慧融村镇银行","ZYCBANK": "贵州银行","KYHNSCZYH": "国民村镇银行","YGCB": "前郭县阳光村镇银行","AHDYMFCZYH": "泌阳玉川村镇银行","SDZPQLCZYH": "芜湖圆融村镇银行","ZJTLCB": "浙江泰隆商业银行","NHB": "南海农商银行","CJCCB": "江苏长江商业银行","FBBANK": "富邦华一银行","LZCCB": "柳州银行","FSCB": "抚顺银行","LJYSCJCZYH": "闻喜县晋融村镇银行","QJHMCB": "曲靖惠民村镇银行","GYSFCB": "廊坊市广阳舜丰村镇银行股份有限公司","CZCCB": "长治银行","NXQTXHLSCZYH": "宁夏青铜峡贺兰山村镇银行","BQGYCZYH": "陕西周至农科村镇银行","LUZBANK": "泸州银行","TJNHCZYH": "天津宁河村镇银行","GSRCU": "甘肃省农村信用社","GLBANK": "桂林银行","PDHF": "大洼恒丰村镇银行","ZZBANK": "郑州银行","SDGQHJCZYH": "山东高青汇金村镇银行","TCRCB": "江苏太仓农村商业银行","HSCZB": "湖商村镇银行","CDRCB": "成都农商银行","YSXRCZYH": "元氏信融村镇银行","YTFSZJCZYH": "汝州玉川村镇银行","WZYTMGJHCZYH": "铁门关津汇村镇银行","ZYXPCZCB": "遵义新蒲长征村镇银行","YDNSCZYH": "尧都农商银行村镇银行","GYRCB": "贵阳农村商业银行","ORBANK": "鄂尔多斯银行","BZSFCB": "霸州舜丰村镇银行","NBYZ": "宁波鄞州农商行","SCB": "渣打银行","JLRCU": "吉林省农村信用社联合社","YNRCC": "云南省农村信用社","OJASZCFCZYH": "宁夏彭阳贺兰山村镇银行"}bank_name = bank_map[bank_abbr]print("银行卡号:{}".format(bank_no))print("银行名称:{}".format(bank_name))print("银行简称:{}".format(bank_abbr))except Exception as e:print("银行卡号输入有误:{}".format(e))if __name__ == '__main__':bank_mes("6217001340011005638")
二、运行效果