网站首页  汉语字词  英语词汇  考试资料  写作素材  旧版资料

请输入您要查询的范文:

 

标题 Python如何读取天气预报
范文
    Python如何读取天气预报?
    import urllib2
    import json
    # 101180101
    url = 'http://m.weather.com.cn/data/101180101.html'
    re = urllib2.urlopen(url).read()
    re = re.decode('UTF-8')
    we = json.loads(re)['weatherinfo']
    print u'城市:' + we['city']
    print u'日期:' + we['date_y']
    print u'week:' + we['week']
    print u'未来6天天气:'
    print '\t' + we['temp1'] + '\t' + we['weather1'] + '\t' + we['wind1']
    print '\t' + we['temp2'] + '\t' + we['weather2'] + '\t' + we['wind2']
    print '\t' + we['temp3'] + '\t' + we['weather3'] + '\t' + we['wind3']
    print '\t' + we['temp4'] + '\t' + we['weather4'] + '\t' + we['wind4']
    print '\t' + we['temp5'] + '\t' + we['weather5'] + '\t' + we['wind5']
    print '\t' + we['temp6'] + '\t' + we['weather6'] + '\t' + we['wind6']
    print u'穿衣指数: '+ we['index_d']
    print u'紫外线: ' + we['index_uv']
    raw_input()
随便看

 

在线学习网范文大全提供好词好句、学习总结、工作总结、演讲稿等写作素材及范文模板,是学习及工作的有利工具。

 

Copyright © 2002-2024 cuapp.net All Rights Reserved
更新时间:2025/5/21 8:52:02