解决字典里面有datatime格式需要进行序列化
https://blog.51cto.com/linyingyong/4989856
序列化
https://blog.csdn.net/weixin_51111267/article/details/124952698
列表里面的也可以序列化datatime
import json
import datetime
class DateEncoder(json.JSONEncoder):
def default(self, obj):
if isinstance(obj, datetime.datetime):
return obj.strftime('%Y-%m-%d %H:%M:%S')
else:
return json.JSONEncoder.default(self, obj)
return json.JSONEncoder.default(self, obj)
id_obje=[{'id': 1, 'patrolname': '任务一', 'tapd_department_id': 1, 'createduser': '0', 'updatauser': '0', 'dingding': '0', 'last_result': 0, 'time': 4, 'status': 1, 'islete': 0, 'create_time': datetime.datetime(2023, 1, 5, 18, 18, 18), 'update_time': datetime.datetime(2025, 1, 5, 18, 18, 24)}]
param_config = json.dumps(list(id_obje), cls=DateEncoder)
print(param_config)
标签:obj,18,datetime,乱码,json,序列化,重写,id From: https://www.cnblogs.com/kaibindirver/p/17029991.html