#encoding:UTF-8 #Python 3.4.3 import urllib import requests ‘‘‘ 天天快递 运单号码: 667612364334 圆通速递 运单号码: 885300598318625893 韵达快递 运单号码: 3839920843883 ‘‘‘ kd=[[‘申通‘,‘shentong‘,0], [‘EMS‘ ,‘ems‘,1], [‘顺丰‘,‘shunfeng‘,2], [‘圆通‘,‘yuantong‘,3], [‘中通‘,‘zhongtong‘,4], [‘韵达‘,‘yunda‘,5], [‘天天‘,‘tiantian‘,6], [‘汇通‘,‘huitongkuaidi‘,7], [‘全峰‘,‘quanfengkuaidi‘,8], [‘德邦‘,‘debangwuliu‘,9], [‘宅急送‘,‘zhaijisong‘,10]] for i in range(len(kd)): print(‘快递公司: ‘,kd[i][0],‘编号: ‘,kd[i][2]) type,postid=input(‘请输入快递编号和快递单号(逗号分隔): ‘).split(‘,‘) company1=‘‘ company2=‘‘ s=int(‘‘+type) for i in range(len(kd)): if kd[i][2]==s: company1=kd[i][0] company2=kd[i][1] url=‘http://www.kuaidi100.com/query?type=%s&postid=%s‘ %(company2,postid) data=urllib.request.urlopen(url).read().decode(‘utf-8‘) dict=eval(data) print(‘ ‘) print(‘**************************************************‘) print(‘快递单号: ‘,dict.get(‘nu‘)) print(‘快递公司: ‘,company1) l=dict.get(‘data‘) for i in range(len(l)): print (‘派件情况:‘,l[i].get(‘time‘),l[i].get(‘context‘))
时间: 2024-10-23 05:46:33