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 基于wxpy库实现微信添加好友功能(简洁)

Python 基于wxpy库实现微信添加好友功能(简洁)

Github:https://github.com/Lyo-hub/wxpy_AddFriend 本程序为基于wxpy库实现的。 1.打开cmd导入一下库。 2.修改库文件中ad...

讲解Python中if语句的嵌套用法

 可能有这样一种情况,当你想检查其他条件后一个条件解析为真。在这种情况下,可以使用嵌套的if结构。 在嵌套的 if 语句结构,可以在一个 if... elif... else...

对Python 多线程统计所有csv文件的行数方法详解

如下所示: #统计某文件夹下的所有csv文件的行数(多线程) import threading import csv import os class MyThreadLine(t...

Python 模拟员工信息数据库操作的实例

Python 模拟员工信息数据库操作的实例

1.功能简介 此程序模拟员工信息数据库操作,按照语法输入指令即能实现员工信息的增、删、改、查功能。 2.实现方法 • 架构: 本程序采用python语言编写,关键在于指令的解...

python opencv实现证件照换底功能

python opencv实现证件照换底功能

本文实例为大家分享了python opencv实现证件照换底功能的具体代码,供大家参考,具体内容如下 思路:先转到HSV空间,利用颜色提取背景制作掩模版mask,然后通过按位操作提取人像...