小编mas*_*kar的帖子

azure 函数:返回 json 对象

import logging
import azure.functions as func

def main(req: func.HttpRequest) -> func.HttpResponse:
    logging.info('Python HTTP trigger function processed a request.')

    name = {"test":"jjj"}
    return func.HttpResponse(name)
Run Code Online (Sandbox Code Playgroud)

上面是我使用 python 预览的 azure 函数(V2)。如果我回来

func.HttpResponse(f"{name}") 
Run Code Online (Sandbox Code Playgroud)

它有效,但如果我返回 dict 对象,则无效。显示的错误是

Exception: TypeError: reponse is expected to be either of str, bytes, or bytearray, got dict
Run Code Online (Sandbox Code Playgroud)

请帮忙。

azure-functions azure-functions-core-tools

9
推荐指数
3
解决办法
1万
查看次数