您现在的位置是:首页 > Python 当前栏目 Python初学10-Json Python 对象 JSON JSON 2023-03-02 11:48:08 时间 **Json** ** 一种轻量级的数据交换格式** **import json** **1、Json字符串转Json对象** #Json 里字符为双引号 json_str = '{"name":"Tom","age":15}' json_obj=json.loads(json_str) print(json_obj,type(json_obj)) print(json_obj['name'],json_obj['age']) json_str = '[{"name":"Tom1","age":151},{"name":"Tom2","age":152}]' json_obj = json.loads(json_str) print(json_obj,type(json_obj)) for i in json_obj: print(i['name'],i['age']) **2、Json对象转json字符串** json_obj = [ {'name':'Tom1','age':101,'flag':False}, {'name':'Tom2','age':102} ] json_str = json.dumps(json_obj) print(type(json_str),json_str) **3、Json 和 Python** ''' json python object dict array list string str number int number float true True null None ''' 本文地址: Python初学10-Json 相关文章 Python Notebook简介 Python 网络编程 Python的特点 快速排序(python) Python学习_1 python 封装 PostgreSQL Python 基础知识 python 快排 Python爬虫-PyQuery Python字典小结 python 元组 python 字典 .get python之socket Python Numpy简介 Python之词典 python urllib.request python_zip函数 python爬虫图片 Python语言概述 Python 命名规范