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脚本实现Web漏洞扫描工具

这是去年毕设做的一个Web漏洞扫描小工具,主要针对简单的SQL注入漏洞、SQL盲注和XSS漏洞,代码是看过github外国大神(听说是SMAP的编写者之一)的两个小工具源码,根据里面的思...

cmd运行python文件时对结果进行保存的方法

cmd运行python文件时对结果进行保存的方法

当用cmd命令行运行python文件时,我们知道可以通过 >python pyfile.py 来运行python文件,此时的输出会直接打印到cmd输出行中,如果希望将运行直接...

django基础之数据库操作方法(详解)

django基础之数据库操作方法(详解)

Django 自称是“最适合开发有限期的完美WEB框架”。本文参考《Django web开发指南》,快速搭建一个blog 出来,在中间涉及诸多知识点,这里不会详细说明,如果你是第一次接触...

MAC中PyCharm设置python3解释器

MAC中PyCharm设置python3解释器

MAC上的PyCharm中默认的python解释器是python2的,windows下的没用过不是很清楚,所以特来记录下设置python3解释器的过程。 python3的查找与安装 如果...

深入理解Python3中的http.client模块

http 模块简介 Python3 中的 http 包中含有几个用来开发 HTTP 协议的模块。 http.client 是一个底层的 HTTP 协议客户端,被更高层的 urlli...