原文:https://blog.csdn.net/suibianshen2012/article/details/64444030
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‘) elif isinstance(obj,date): return obj.strftime("%Y-%m-%d") else: return json.JSONEncoder.default(self,obj)
原文地址:https://www.cnblogs.com/bubutianshu/p/12371459.html
时间: 2024-11-10 15:46:08