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')

相关文章

ActiveMQ:使用Python访问ActiveMQ的方法

ActiveMQ:使用Python访问ActiveMQ的方法

Windows 10家庭中文版,Python 3.6.4,stomp.py 4.1.21 ActiveMQ支持Python访问,提供了基于STOMP协议(端口为61613)的库。 Act...

flask + pymysql操作Mysql数据库的实例

flask + pymysql操作Mysql数据库的实例

安装flask-sqlalchemy、pymysql模块 pip install flask-sqlalchemy pymysql ### Flask-SQLAlchemy的介绍...

python登录豆瓣并发帖的方法

本文实例讲述了python登录豆瓣并发帖的方法。分享给大家供大家参考。具体如下: 这里涉及urllib、urllib2及cookielib常用方法的使用 登录豆瓣,由于有验证码,采取的办...

Python实现计算最小编辑距离

Python实现计算最小编辑距离

最小编辑距离或莱文斯坦距离(Levenshtein),指由字符串A转化为字符串B的最小编辑次数。允许的编辑操作有:删除,插入,替换。具体内容可参见:维基百科—莱文斯坦距离。一般代码实现的...

python使用BeautifulSoup分页网页中超链接的方法

本文实例讲述了python使用BeautifulSoup分页网页中超链接的方法。分享给大家供大家参考。具体如下: python通过BeautifulSoup分页网页中的超级链接,这段py...