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实现冒泡排序算法实例代码

利用python实现冒泡排序算法实例代码

冒泡排序 冒泡排序(英语:Bubble Sort)是一种简单的排序算法。它重复地遍历要排序的数列,一次比较两个元素,如果他们的顺序错误就把他们交换过来。遍历数列的工作是重复地进行直到没...

Python2与python3中 for 循环语句基础与实例分析

Python2与python3中 for 循环语句基础与实例分析

下面的代码中python2与python3的print使用区别,大家注意一下。python3需要加()才行。 语法: for循环的语法格式如下: for iterating_var...

python绘图模块matplotlib示例详解

python绘图模块matplotlib示例详解

前言 Matplotlib 是 Python 的绘图库。作为程序员,经常需要进行绘图,在我自己的工作中,如果需要绘图,一般都是将数据导入到excel中,然后通过excel生成图表,这样操...

python引用DLL文件的方法

本文实例讲述了python引用DLL文件的方法。分享给大家供大家参考。具体分析如下: 在python中调用dll文件中的接口比较简单,如我们有一个test.dll文件,内部定义如下:...

python实现机器人行走效果

本文实例为大家分享了python实现机器人行走效果的具体代码,供大家参考,具体内容如下 #! /usr/bin/env python3 # -*- coding: utf-8 -*...