python显示天气预报

yipeiwu_com5年前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定时任务 sched模块用法实例

这篇文章主要介绍了python定时任务 sched模块用法实例,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友可以参考下 通过sched模块可以实...

python通过文件头判断文件类型

对于提供上传的服务器,需要对上传的文件进行过滤。 本文为大家提供了python通过文件头判断文件类型的方法,避免不必要的麻烦。 分享代码如下 import struct # 支...

python os.path.isfile()因参数问题判断错误的解决

目的: 找出路径坐在的所有python文件(.py结尾),返回列表。 代码: def list_py(path = None): if path == None: path =...

Python tensorflow实现mnist手写数字识别示例【非卷积与卷积实现】

本文实例讲述了Python tensorflow实现mnist手写数字识别。分享给大家供大家参考,具体如下: 非卷积实现 import tensorflow as tf from t...

python正则表达式面试题解答

三道python正则表达式面试题,具体如下 1.去除以下html文件中的标签,只显示文本信息。 <div> <p>岗位职责:</p> <p&...