简要咨询咨询QQ网站导航网站搜索手机站点联系我们设为首页加入收藏 

Python如何读取天气预报

来源:易贤网   阅读:1866 次  日期:2015-04-15 14:44:50

温馨提示:易贤网小编为您整理了“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()

更多信息请查看IT技术专栏

更多信息请查看CMS教程
点此处就本文及相关问题在本站进行非正式的简要咨询(便捷快速)】     【点此处查询各地各类考试咨询QQ号码及交流群
上一篇:java实现多线程总结
下一篇:织梦(dede)arclist标签调用交叉栏目时调不出来
易贤网手机网站地址:Python如何读取天气预报
由于各方面情况的不断调整与变化,易贤网提供的所有考试信息和咨询回复仅供参考,敬请考生以权威部门公布的正式信息和咨询为准!
相关阅读      CMS教程