把sqlalchemy对象转化成json数据类型
def to_json_all(msg: list):
data = []
if type(msg) == list:
for i in range(len(msg)):
temp_dict = {}
j = 0
for k, v in msg[i].__dict__.items():
if j > 0:
temp_dict[k] = v
j += 1
data.append(temp_dict)
else:
temp_dict = {}
j = 0
for k, v in msg.__dict__.items():
if j > 0:
temp_dict[k] = v
j += 1
data = temp_dict
return data
标签:sqlalchemy,temp,数据类型,json,dict,msg,data
From: https://www.cnblogs.com/bitterteaer/p/16784943.html