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 pygame实现2048游戏

python pygame实现2048游戏

实现2048相对来说比较简单,用4*4的二维数组保存地图,pygame.key.get_pressed()获取键盘操作,详见代码。 效果图 代码 # -*- coding: ut...

python 图片二值化处理(处理后为纯黑白的图片)

python 图片二值化处理(处理后为纯黑白的图片)

先随便招一张图片test.jpg做案例 然后对图片进行处理 # 图片二值化 from PIL import Image img = Image.open('test.jpg')...

Pandas时间序列:重采样及频率转换方式

如下所示: import pandas as pd import numpy as np 一、介绍 重采样(resampling)指的是将时间序列从一个频率转换到另一个频率的处理过...

使用python PIL库实现简单验证码的去噪方法步骤

使用python PIL库实现简单验证码的去噪方法步骤

字符型图片验证码识别完整过程及Python实现的博主,我的大部分知识点都是从他那里学来的。 想要识别验证码,收集足够多的样本后,首先要做的就是对验证码原始图片进行处理,对验证码识别分类之...

简单谈谈python中的多进程

进程是由系统自己管理的。 1:最基本的写法 from multiprocessing import Pool def f(x): return x*x if __name__...