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操作excel文件的实例代码

使用的类库 pip install openpyxl 操作实现 •工作簿操作 # coding: utf-8 from openpyxl import Workbook...

Python实现的飞速中文网小说下载脚本

1.JavaScript 加密什么的最讨厌了 :-( 1).eval 一个不依赖外部变量的函数立即调用很天真,看我 nodejs 来干掉你! 2).HTTP 请求的验证首先尝试 Refe...

PyCharm代码整体缩进,反向缩进的方法

如下所示: 整体缩进:鼠标拉选住代码块,按下tab键。 反向缩进:鼠标拉选住代码块,按下tab+shift键。 以上这篇PyCharm代码整体缩进,反向缩进的方法就是小编分享给大家的全部...

PyQt打开保存对话框的方法和使用详解

PyQt之打开保存对话框(QFileDialog)的方法和使用 一、控件说明 QFileDialog是用于打开和保存文件的标准对话框,继承自QDialog类。 QFileDialog在打...

Python实现从log日志中提取ip的方法【正则提取】

本文实例讲述了Python实现从log日志中提取ip的方法。分享给大家供大家参考,具体如下: log日志内容如下(myjob.log): 124.90.53.68 - - [05/F...