Python Json获取天气预报
2016-01-07 15:50
447 查看
#!/usr/bin/python # -*- coding: UTF-8 -*- import json import smtplib import urllib from email.mime.text import MIMEText def getHtml(url): page = urllib.urlopen(url) html = page.read() return html.decode("utf-8") str = getHtml("http://api.map.baidu.com/telematics/v3/weather?location=沈阳&output=json&ak=Dy2Zop7tjKlj2EZxwe88Hbjz") _json = json.loads(str)["results"] _json = _json[0]["weather_data"]; print("沈阳天气:".decode("utf-8")) for i in range(0, 4): print(_json[i]["date"] + " " + _json[i]["weather"] + " " + _json[i]["wind"] + " " + _json[i]["temperature"]);
相关文章推荐
- Python发送邮件
- 笨方法学Python(46-50)
- [Leetcode]@python 62. Unique Paths
- Python 对图片进行人脸识别
- 黑科技 Python脚本帮你找出微信上删除你好友的人
- [Leetcode]@python 61. Rotate List
- python re的几个函数
- numpy安装
- python 大数据分析
- Python学习笔记
- Python fabric实现远程操作和部署
- 5.1.4. List Comprehensions(列表解析)
- windows下,python+scrapy环境搭建
- python 线程使用
- python 学习笔记 if语句
- Python系列之 - python数据类型(二)
- visual studio 2015使用python tools远程调试maya 2016
- python 实例7 为rhel添加系统用户与登录密码,并给root 发送邮件
- 【Python那些事儿之七】Iterators详解
- Python程序员最常犯的十个错误