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实现的汉诺塔算法示例

本文实例讲述了python实现的汉诺塔算法。分享给大家供大家参考,具体如下: 规则: 圆盘从下面开始按大小顺序重新摆放在另一根柱子上。并且规定 在小圆盘上不能放大圆盘 在三根...

在Pandas中给多层索引降级的方法

# 背景介绍 通常我们不会在Pandas中主动设置多层索引,但是如果一个字段做多个不同的聚合运算, 比如sum, max这样形成的Column Level是有层次的,这样阅读非常方便,但...

Python解析网页源代码中的115网盘链接实例

本文实例讲述了python解析网页源代码中的115网盘链接的方法。分享给大家供大家参考。具体方法分析如下: 其中的1.txt,是网页http://bbs.pediy.com/showth...

梅尔倒谱系数(MFCC)实现

本文实例为大家分享了梅尔倒谱系数实现代码,供大家参考,具体内容如下 """ @author: zoutai @file: mymfcc.py @time: 2018/03/26...

python 2.7 检测一个网页是否能正常访问的方法

如下所示: #!/bin/env python #coding:utf-8 import requests import sys url = "https://mp.csdn...