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使用递归的方式建立二叉树

树和图的数据结构,就很有意思啦。 # coding = utf-8 class BinaryTree: def __init__(self, root_obj)...

pip matplotlib报错equired packages can not be built解决

pip安装matplotlib 在centos6.5 64bit上用pip安装matplotlib时候报错: * The following required packages ca...

对python:threading.Thread类的使用方法详解

Python Thread类表示在单独的控制线程中运行的活动。有两种方法可以指定这种活动: 1、给构造函数传递回调对象 mthread=threading.Thread(target...

基于PyQt4和PySide实现输入对话框效果

基于PyQt4和PySide实现输入对话框效果

今天做了个基于PyQt4和PySide的输入对话框.已放到PyPi中,包名wlab,大家可以使用pip安装: pip install wlab 在程序输入中,有时会要求同时改变多个参...

python 列表,数组,矩阵两两转换tolist()的实例

通过代码熟悉过程: # -*- coding: utf-8 -*- from numpy import * a1 =[[1,2,3],[4,5,6]] #列表 print('a1 :...