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辅助软件思路及图像识别源码解析

本文将梳理github上最火的wechat_jump_game的实现思路,并解析其图像处理部分源码 首先废话少说先看效果 核心思想 获取棋子到下一个方块的中心点的距离 计算触摸屏...

pymongo给mongodb创建索引的简单实现方法

本文实例讲述了pymongo给mongodb创建索引的简单实现方法。分享给大家供大家参考。具体如下: 下面的代码给user的user_name字段创建唯一索引 import pymo...

python opencv判断图像是否为空的实例

如下所示: import cv2 im = cv2.imread('2.jpg') if im is None: print("图像为空") # cv2.imshow("ss...

python中map的基本用法示例

python中map的基本用法示例

map()函数 map() 会根据提供的函数对指定序列做映射,是内置函数 第一个参数 function 以参数序列中的每一个元素调用 function 函数,返回包含每次 functi...

Python调用命令行进度条的方法

本文实例讲述了Python调用命令行进度条的方法。分享给大家供大家参考。具体分析如下: 关键点是输出'\r'这个字符可以使光标回到一行的开头,这时输出其它内容就会将原内容覆盖。 im...