王锋

王锋的博客

他的个人主页  他的博客

sdfafd

王锋  2015年12月02日 星期三 16:22 | 1062次浏览 | 0条评论

sfaasdf

# -*- coding: utf-8 -*-
import sys, urllib, urllib2, json

url = 'http://apis.baidu.com/apistore/weatherservice/weather?citypinyin=beijing'


req = urllib2.Request(url)

req.add_header("apikey", "ec1c4e765803f8a8862620fb66dac5c8")

resp = urllib2.urlopen(req)
content = resp.read()
if(content):
    cs = json.loads(content)
if cs['errMsg']=="success":
    wc=cs["retData"]
    city  = wc['city']
    date = wc['date']
    time = wc['time']
    weather = wc['weather']
    contents = city+date+u"天气"+weather
    print contents

评论

我的评论:

发表评论

请 登录 后发表评论。还没有在Zeuux哲思注册吗?现在 注册 !

暂时没有评论

Zeuux © 2024

京ICP备05028076号