最新下载
热门教程
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
Python 读取天气预报例子
时间:2014-02-23 编辑:简简单单 来源:一聚教程网
在Linux下执行以下代码会有这样的效果出来,想不想试试哈?
代码如下 | 复制代码 |
#coding:utf-8 import urllib2 import json # 101230201 厦门编码号 url = 'http://m.weather.com.cn/data/101230201.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() |
-
上一个: php中英文字符串长度截取的例子
-
下一个: Python学习笔记之自定义函数
相关文章
- java怎么读取键盘输入?Java中接收键盘输入的三种方法 02-16
- Word怎么读生僻字 巧用Word 读取生僻字 09-23
- 下班前一贴,用wsh读取registry. 01-18
- 我要直接读取请求的信息头,我要怎么做? 01-12
- PHP导出数据超时的优化建议解读 10-31
- PHP之mysql位运算解析 10-31