RODY/app/utils/JSONEncodeTools.py
552068321@qq.com 6f7de660aa first commit
2022-11-04 17:37:08 +08:00

21 lines
434 B
Python
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

"""
@Time 2022/10/17 10:12
@Auth
@File JSONEncodeTools.py
@IDE PyCharm
@MottoABC(Always Be Coding)
@Desc
"""
import datetime
import json
class MyEncoder(json.JSONEncoder):
def default(self, obj):
if isinstance(obj, bytes):
return str(obj, encoding='utf-8')
if isinstance(obj, datetime.datetime):
return str(obj)
return json.JSONEncoder.default(self, obj)