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')

相关文章

详解TensorFlow在windows上安装与简单示例

详解TensorFlow在windows上安装与简单示例

本文介绍了详解TensorFlow在windows上安装与简单示例,分享给大家,具体如下: 安装说明 平台:目前可在Ubuntu、Mac OS、Windows上安装 版本:提供gpu...

python实现抖音点赞功能

本文实例为大家分享了python实现抖音点赞功能的具体代码,供大家参考,具体内容如下 #coding=utf-8 from time import sleep, ctime imp...

python实现保存网页到本地示例

学习python示例:实现保存网页到本地复制代码 代码如下:#coding=utf-8__auther__ = 'xianbao'import urllibimport osdef re...

新手入门Python编程的8个实用建议

新手入门Python编程的8个实用建议

前言 我们在用Python进行机器学习建模项目的时候,每个人都会有自己的一套项目文件管理的习惯,我自己也有一套方法,是自己曾经踩过的坑踩过的雷总结出来的,现在在这里分享一下给大家,因为很...

python自动化测试之连接几组测试包实例

本文实例讲述了python自动化测试之连接几组测试包的方法,分享给大家供大家参考。具体方法如下: 具体代码如下: class RomanNumeralConverter(object...