• 欢迎访问搞代码网站,推荐使用最新版火狐浏览器和Chrome浏览器访问本网站!
  • 如果您觉得本站非常有看点,那么赶紧使用Ctrl+D 收藏搞代码吧

Python3 处理JSON的实例详解

python 搞代码 4年前 (2022-01-08) 18次浏览 已收录 0个评论

这篇文章主要介绍了Python3 处理JSON的实例详解的相关资料,希望通过本文能帮助到大家,让大家实现这样的功能,需要的朋友可以参考下

Python3 处理JSON的实例详解

真的好简单,灰常简单

 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"]["tem<strong style="color:transparent">来源gaodai#ma#com搞@代~码网</strong>p1"] print("温度: ", szTemp) szWeather1 = jsonData["weatherinfo"]["weather1"] print("天气情况: ",szWeather1) szCityid = jsonData["weatherinfo"]["cityid"] print("城市编码: ",szCityid) if __name__ == '__main__': main() 

如有疑问请留言或者到本站社区交流讨论,感谢阅读,希望能帮助到大家,谢谢大家对本站的支持!

以上就是Python3 处理JSON的实例详解的详细内容,更多请关注gaodaima搞代码网其它相关文章!


搞代码网(gaodaima.com)提供的所有资源部分来自互联网,如果有侵犯您的版权或其他权益,请说明详细缘由并提供版权或权益证明然后发送到邮箱[email protected],我们会在看到邮件的第一时间内为您处理,或直接联系QQ:872152909。本网站采用BY-NC-SA协议进行授权
转载请注明原文链接:Python3 处理JSON的实例详解
喜欢 (0)
[搞代码]
分享 (0)
发表我的评论
取消评论

表情 贴图 加粗 删除线 居中 斜体 签到

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址