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实现简单查找最长子串功能。分享给大家供大家参考,具体如下: 题目选自edX公开课 MITx: 6.00.1x Introduction to Computer...

windows及linux环境下永久修改pip镜像源的方法

windows及linux环境下永久修改pip镜像源的方法

一、在windows环境下修改pip镜像源的方法(以python3.5为例) (1):在windows文件管理器中,输入 %APPDATA% (2):会定位到一个新的目录下,在该目...

python实现搜索本地文件信息写入文件的方法

python实现搜索本地文件信息写入文件的方法

本文实例讲述了python实现搜索本地文件信息写入文件的方法。分享给大家供大家参考,具体如下: 主要功能: 在指定的盘符,如D盘,搜索出与用户给定后缀名(如:jpg,png)相关的文件,...

Python中列表和元组的使用方法和区别详解

一、二者区别 列表: 1.可以增加列表内容 append 2.可以统计某个列表段在整个列表中出现的次数 count 3.可以插入一个字符串,并把整个字符串的每个字母拆分当作一个列...

python2 与python3的print区别小结

在Python2和Python3中都提供print()方法来打印信息,但两个版本间的print稍微有差异 主要体现在以下几个方面: 1.python3中print是一个内置函数,有多个参...