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

相关文章

pycharm 使用心得(三)Hello world!

pycharm 使用心得(三)Hello world!

1,新建一个项目 File --> New Project... 2,新建一个文件右键单击刚建好的helloWord项目,选择New --> Python File 3,...

python使用分治法实现求解最大值的方法

本文实例讲述了python使用分治法实现求解最大值的方法。分享给大家供大家参考。具体分析如下: 题目: 给定一个顺序表,编写一个求出其最大值和最小值的分治算法。 分析: 由于顺序表的结构...

Python用imghdr模块识别图片格式实例解析

imghdr模块 功能描述:imghdr模块用于识别图片的格式。它通过检测文件的前几个字节,从而判断图片的格式。 唯一一个API imghdr.what(file, h=None) 第一...

Python实现滑动平均(Moving Average)的例子

Python中滑动平均算法(Moving Average)方案: #!/usr/bin/env python # -*- coding: utf-8 -*- import nump...

Django Admin中增加导出Excel功能过程解析

Django Admin中增加导出Excel功能过程解析

在使用Django Admin时, 对于列表我们有时需要提供数据导出功能, 如下图: 增加导出Excel功能 在Django Admin中每个模型的Admin类(继承至admin.M...