4_1 ptyhon对象转json字符串
2021-02-04 20:17
标签:bsp 函数 open utf-8 文件 name nbsp count span 4_1 ptyhon对象转json字符串 标签:bsp 函数 open utf-8 文件 name nbsp count span 原文地址:https://www.cnblogs.com/sruzzg/p/13138132.html 1 """ptyhon对象转json字符串"""
2
3
4 import json
5
6 persons = [
7 {‘username‘: ‘张三‘, ‘age‘: 18, ‘country‘: ‘china‘},
8 {‘username‘: ‘lisi‘, ‘age‘: 20, ‘country‘: ‘USA‘}
9 ]
10 # 使用dumps函数据把列表转成json字符串
11 json_str = json.dumps(persons)
12 print(type(json_str)) #
文章标题:4_1 ptyhon对象转json字符串
文章链接:http://soscw.com/index.php/essay/51053.html