__author__ = ‘zhaobin022‘ import json from datetime import datetime class JsonCustomEncoder(json.JSONEncoder): def default(self,field): if isinstance(field,datetime): return field.strftime(‘%Y-%m-%d %H:%M:%S‘) obj = {‘d‘:datetime.now()} ds = json.dumps(obj,cls=JsonCustomEncoder) print(ds)
__author__ = ‘zhaobin022‘import jsonfrom datetime import datetime class JsonCustomEncoder(json.JSONEncoder): def default(self,field): if isinstance(field,datetime): return field.strftime(‘%Y-%m-%d %H:%M:%S‘) obj = {‘d‘:datetime.now()}ds = json.dumps(obj,cls=JsonCustomEncoder)print(ds)
时间: 2024-10-07 08:55:31