码迷,mamicode.com
首页 > 其他好文 > 详细

快递查询

时间:2017-06-06 11:57:02      阅读:144      评论:0      收藏:0      [点我收藏+]

标签:zha   UI   read   inpu   request   data   bsp   int   com   

#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‘))
    


    
    
    
    
    
    
    
    
    
    
    

 

快递查询

标签:zha   UI   read   inpu   request   data   bsp   int   com   

原文地址:http://www.cnblogs.com/stay-hungry/p/6950655.html

踩
(0)
赞
(0)
   
举报
评论 一句话评论(0)
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!