python3处理json
2013-07-04 09:58
253 查看
转载,就这么处理就可以了。
import os, io, sys, re, time, base64, json import webbrowser, urllib.request def main(): "main function" url = "http://m.weather.com.cn/data/101010100.html" stdout=urllib.request.urlopen(url) weatherInfo= stdout.read().decode('utf-8') #print(weatherInfo) jsonData = json.loads(weatherInfo) #输出JSON数据 szCity = jsonData["weatherinfo"]["city"] print("城市: ", szCity) szTemp = jsonData["weatherinfo"]["temp1"] print("温度: ", szTemp) szWeather1 = jsonData["weatherinfo"]["weather1"] print("天气情况: ",szWeather1) szCityid = jsonData["weatherinfo"]["cityid"] print("城市编码: ",szCityid) if __name__ == '__main__': main()
相关文章推荐
- python json转换与处理
- Python 处理JSON数据报错解决办法
- Python JSON格式处理
- python 处理json
- python处理JSON格式数据并利用pygal绘制世界地图
- python 正则表达式处理不规范json
- Python处理JSON
- python默认json库处理mysql中datetime,date类型不能序列化json的解决方案
- Python3 网络传输数据的处理(json / xml / base64)
- Python处理json数据
- Python处理JSON
- JSON 基础 + PHP 处理 JSON + Python 处理 JSON
- Python3 处理JSON
- Python处理json字符串转化为字典
- Python3 网络传输数据的处理(json / xml / base64)
- Python处理json字符串转化为字典的简单实现
- python处理json
- python处理json数据中的中文
- Python处理JSON
- python使用json序列化datetime类型问题处理