import json

class User(object):

    def __init__(self, username, theme,image):
        self.username = username
        self.theme = theme
        self.image = image

@app.route("/me1")
def me_api1():
    user = User('wxy','theme','image')
    return json.dumps(user, default=lambda obj: obj.__dict__)

  类转换为字典

 json.dumps(user, default=lambda obj: obj.__dict__)

  

相关文章:

  • 2022-12-23
  • 2021-11-04
  • 2022-12-23
  • 2021-08-17
  • 2022-12-23
  • 2022-12-23
  • 2021-09-20
  • 2022-12-23
猜你喜欢
  • 2021-11-27
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-03-02
  • 2022-12-23
相关资源
相似解决方案