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

相关文章

在Pycharm中自动添加时间日期作者等信息的方法

在Pycharm中自动添加时间日期作者等信息的方法

1.按照下面路径以此打开 File→→Settings→→Editor→→File and code Templates 右侧找到Python Script,如下图 2.设置相...

Flask框架使用DBUtils模块连接数据库操作示例

本文实例讲述了Flask框架使用DBUtils模块连接数据库的操作方法。分享给大家供大家参考,具体如下: Flask连接数据库 数据库连接池: Django使用:django ORM(p...

python 字符串split的用法分享

比如我们的存储的格式的:格式的:姓名,年龄|另外一个用户姓名,年龄name:haha,age:20|name:python,age:30|name:fef,age:55那我们可以通过字符...

python gensim使用word2vec词向量处理中文语料的方法

python gensim使用word2vec词向量处理中文语料的方法

word2vec介绍 word2vec官网:https://code.google.com/p/word2vec/ word2vec是google的一个开源工具,能够根据输入的词...

速记Python布尔值

在python中。布尔值有 Ture False 两种。Ture等于对,False等于错。要注意在python中对字母的大小写要求非常严格。 Ture 和 False 的首字母都要大写。...