flask orm 对象序列化

def orm_serialize(item) -> dict:
    if item:
        try:
            return {c.name: getattr(item, c.name) for c in item.__table__.columns}
        except:
            return {}
    else:
        return {}
posted @ 2024-04-07 15:42  bitterteaer  阅读(5)  评论(0编辑  收藏  举报