Python返回对象

Joe*_*Joe -4 python

我如何让 Python 返回这样的东西:

{ "status": error,
  "location": loc,
  "codes": {
      "code1": 5,
      "code2": 6,
  },
}
Run Code Online (Sandbox Code Playgroud)

我认为这看起来像一个 JSON 对象?

Bry*_*ley 6

从字面上看,“我如何返回此 dict”的答案是返回此 dict

def some_function():
    return {
        "status": error,
        "location": loc,
        "codes": {
            "code1": 5,
            "code2": 6,
        },
    }
Run Code Online (Sandbox Code Playgroud)