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表白工具 你喜欢我吗

本文实例为大家分享了python表白工具的具体代码,供大家参考,具体内容如下 实现代码: # 打包操作 # 安装pyinstaller # cmd输入 pip install pyi...

如何使用python实现模拟鼠标点击

这篇文章主要介绍了如何使用python实现模拟鼠标点击,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友可以参考下 不知道大家在工作中有没有一些工作...

python基础_文件操作实现全文或单行替换的方法

python修改文件时,使用w模式会将原本的文件清空/覆盖。可以先用读(r)的方式打开,写到内存中,然后再用写(w)的方式打开。 1、替换文本中的taste 为 tasting Ye...

Python3处理HTTP请求的实例

Python3处理HTTP请求的实例

Python3处理HTTP请求的包:http.client,urllib,urllib3,requests 其中,http 比较 low-level,一般不直接使用 urllib更 hi...

Python中的上下文管理器相关知识详解

Python中的上下文管理器相关知识详解

前言 with 这个关键字,对于每一学习Python的人,都不会陌生。 操作文本对象的时候,几乎所有的人都会让我们要用 with open ,这就是一个上下文管理的例子。你一定已经相当...