一个自定义的json序列化对象的方法
import json
def json_encode(o):
t = type(o)
if t is list or t is tuple:
return json.dumps([oo.__dict__ for oo in o])
else:
return json.dumps(o.__dict__)
import json
def json_encode(o):
t = type(o)
if t is list or t is tuple:
return json.dumps([oo.__dict__ for oo in o])
else:
return json.dumps(o.__dict__)