Python 天气预报
来源:互联网 发布:2017最流行编程语言 编辑:程序博客网 时间:2024/06/02 04:53
# !/usr/bin/env python# coding=utf-8import httplibimport jsonhttpClient = Nonetry: httpClient = httplib.HTTPConnection('api.map.baidu.com', 80, timeout=30) httpClient.request('GET', '/telematics/v3/weather?location=%E6%AD%A6%E6%B1%89&output=json&ak=KPGX6sBfBZvz8NlDN5mXDNBF&callback=') response = httpClient.getresponse() s = json.loads(response.read()); print s["results"][0]["currentCity"] print s["results"][0]["weather_data"][0]["date"] print s["results"][0]["weather_data"][0]["weather"] print s["results"][0]["weather_data"][0]["wind"] print s["results"][0]["weather_data"][0]["temperature"]except Exception, e: print efinally: if httpClient: httpClient.close()/System/Library/Frameworks/Python.framework/Versions/2.7/bin/python2.7 /Users/wangms/PycharmProjects/Python/weather/weather.py武汉周五 08月04日 (实时:33℃)阵雨转多云无持续风向微风35 ~ 27℃Process finished with exit code 0
阅读全文
0 0
- python天气预报
- python 天气预报
- Python 天气预报
- python 的查询天气预报
- python 实现天气预报功能
- Python读取天气预报
- Python查询天气预报
- python获取天气预报
- 初学Python---------------天气预报
- Python查询天气预报
- Python接入天气预报api
- python 天气预报获取
- 【python 天气预报】python制作属于自己的天气预报
- python for android : 天气预报 API
- python 获取省份的天气预报
- 天气预报
- 天气预报
- 天气预报
- MATLAB 2015B 破解版 安装详细教程
- C语言实现并行求和算法
- androidstudio cmake指定so文件输出目录
- java迭代器自实现
- HashMap和Hashtable
- Python 天气预报
- 利用sklearn做房价预测
- Eclipse配置Struts2问题:ClassNotFoundException: org...dispatcher.ng.filter.StrutsPrepareAndExecuteFilter
- js模块化开发三
- React路由
- Hadoop 完全分布式 Fully-Distributed Mode
- pip install 时报Read timed out错时解决办法
- Nginx 作为反向代理优化要点proxy_buffering
- 编程练习2(二)