重用json模块中类的方法并派生出新的功能
继承json模块,重用模块中类的方法并派生出新的功能
例:使用json模块序列化字符串
import json
from datetime import datetime, date
dict1 = {
# "time1": str(datetime.now())
"time1": datetime.now(),
"name": "orange"
}
res = json.dumps(dict1)
# 无法序列datetime.now()格式,报错
print(res) # TypeError: Object of type datetime is not JSON serializable

![重用json模块中类的方法并派生出新的功能[Python常见问题]](https://www.zixueka.com/wp-content/uploads/2023/10/1696831037-f592b0f9b739162.jpg)
