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 添加用户设置密码并发邮件给root用户

#!/usr/bin/env python #coding: utf8 import os import sys import mkpasswd //这是之前写的,直接调用 impo...

python操作gmail实例

本文实例讲述了python操作gmail的方法。分享给大家供大家参考。 具体实现方法如下: 复制代码 代码如下:import imaplib, re   class pygma...

在flask中使用python-dotenv+flask-cli自定义命令(推荐)

最近在重构 flask 项目的时候发现项目的环境变量异常的混乱,非常不便于管理。而且,更重要的事情是我需要通过自定义命令来运行 devlopment 和 p...

python向已存在的excel中新增表,不覆盖原数据的实例

每月需更新某个excel表格,进行两项操作,且不覆盖原有的sheet: 1. 在原来的excel表中新增sheet 2. 往原有的excel表中的某张sheet新增内容 基于python...

python二维码操作:对QRCode和MyQR入门详解

python二维码操作:对QRCode和MyQR入门详解

python是所有编程语言中模块最丰富的 生活中常见的二维码功能在使用python第三方库来生成十分容易 三个大矩形是定位图案,用于标记二维码的大小。这三个定位图案有白边,通过这三个矩...