Python JSON 转换
python3的json.loads不支持encoding
#python3.11 JSON序列化、反序列化
import json
def
data = ’{ \
"Message": "消息", \ "Timestamp": "时间戳" \ }' #字符串转换编码集为UTF-8 json_str = data.encode('utf-8') #加载json字符串到对象,反序列化 json_obj = json.loads(json_str) #输出json对象 print(json_obj) #转换对象为字符串,序列化 json_string = json.dumps(json_obj, indent=4, ensure_ascii=False) #输出JSON字符串 print(json_string) 标签:obj,json,JSON,字符串,序列化,Python3 From: https://www.cnblogs.com/cancode/p/18002711