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命令行工具Click快速掌握

前言 写 Python 的经常要写一些命令行工具,虽然标准库提供有命令行解析工具 Argparse,但是写起来非常麻烦,我很少会使用它。命令行工具中用起来最爽的就是 Click,它是 F...

python使用itchat库实现微信机器人(好友聊天、群聊天)

itchat是一个开源的微信个人号接口,可以使用该库进行微信网页版中的所有操作,比如:所有好友、添加好友、拉好友群聊、微信机器人等等。详细用户请看文档介绍,在这里。 本文主要使用该库完成...

Python数据分析pandas模块用法实例详解

本文实例讲述了Python数据分析pandas模块用法。分享给大家供大家参考,具体如下: pandas pandas10分钟入门,可以查看官网:10 minutes to pandas...

Python写的创建文件夹自定义函数mkdir()

Python对文件的操作还算是方便的,只需要包含os模块进来,使用相关函数即可实现目录的创建。 主要涉及到三个函数: 1、os.path.exists(path) 判断一个目录是否存在...

python使用matplotlib画饼状图

python使用matplotlib画饼状图

本文实例为大家分享了python使用matplotlib画饼状图的具体代码,供大家参考,具体内容如下 代码与详细注释 from matplotlib import pyplot...