• 周二. 9月 27th, 2022

5G编程聚合网

5G时代下一个聚合的编程学习网

热门标签

python json dumps() loads()

admin

11月 28, 2021

dumps() 转换成json

loads() 转换成dict

import json

dict = {'a': 'wo', 'b': 'zai', 'c': 'zhe', 'd': 'li'}
string = json.dumps(dict)
loads = json.loads(string)

print("type(string):", type(string))
print("type(loads):", type(loads))

print("string:", string)
print("loads:", loads)
type(string): <class 'str'>
type(loads): <class 'dict'>
string: {"a": "wo", "b": "zai", "c": "zhe", "d": "li"}
loads: {'a': 'wo', 'b': 'zai', 'c': 'zhe', 'd': 'li'}
Please call me JiangYouDang!

发表回复

您的电子邮箱地址不会被公开。