python显示天气预报

yipeiwu_com6年前Python基础

复制代码 代码如下:

import urllib2
import json
import string
url ='http://m.weather.com.cn/data/101090502.html'
re = urllib2.urlopen(url).read()
we = json.loads(re)['weatherinfo']
print we['city'] , we['date_y'].center(30) ,   we['week']
print we['temp1'], we['weather1'].center(30),  we['wind1']
print we['temp2'], we['weather2'].center(30),  we['wind2']
print we['temp3'], we['weather3'].center(30),  we['wind3']
print we['temp4'], we['weather4'].center(30),  we['wind4']
print we['temp5'], we['weather5'].center(30),  we['wind5']
print we['temp6'], we['weather6'].center(30),  we['wind6']
print we['index48_d']
raw_input('plese input Enter to esc')

相关文章

python静态方法实例

本文实例讲述了python静态方法。分享给大家供大家参考。 具体实现方法如下: 复制代码 代码如下:staticmethod Found at: __builtin__ staticme...

Python的UTC时间转换讲解

UTC时间转换,最终得到的都是UTC时间。 简单来说就是: 时间戳(timestamp) 转换-> UTC显示时间(datetime),使用time.gmtime(timestam...

使用Python的Tornado框架实现一个简单的WebQQ机器人

我打算将WebQQ单独出来运行, 一开始直接拷贝了pyxmpp2的mainloop, 但是跑起来问题多多, 所以我又研究了利用Tornado进行网络编程(这里), 所以我放弃了Pyxmp...

Python测试网络连通性示例【基于ping】

Python测试网络连通性示例【基于ping】

本文实例讲述了Python测试网络连通性。分享给大家供大家参考,具体如下: Python代码 #!/usr/bin/python # -*- coding:GBK -*- """Do...

python 实现查询Neo4j多节点的多层关系

python 实现查询Neo4j多节点的多层关系

需求:查询出满足3人及3案有关系的集合 # -*- coding: utf-8 -*- from py2neo import Graph import psycopg2 # 二维数...