OpenWhisk Python操作失败,未返回字典

2024-06-02 20:57:23 发布

您现在位置:Python中文网/ 问答频道 /正文

我正在尝试使用OpenWhisk运行此函数:

def main():
    return {"payload": "Hello world"}

包括以下内容:

^{2}$

在本地运行函数时,将返回一个字典,但运行上述命令会出现以下错误:

"result": {
        "error": "The action did not return a dictionary."
    }

我错过了什么?在


Tags: the函数命令helloworldreturn字典main
2条回答

将代码更改为:

def main(args):
    return {"payload": "Hello world"}

The Python actions consume and produce a dictionary。因此,您需要“args”。在

main()输入不能为空接受dict-like main(args)

def main(args):
    return {"payload": "Hello world"}

相关问题 更多 >