擅长:python、mysql、java
<p>两个问题:</p>
<ol>
<li><p>python函数定义错误</p></li>
<li><p>Lambda的主处理程序需要2个参数</p></li>
</ol>
<p>回答:</p>
<pre><code>def hello_world(event_data, lambda_config):
print "hello world"
</code></pre>
<p>有关主处理程序参数的详细信息,请阅读<a href="http://docs.aws.amazon.com/lambda/latest/dg/python-programming-model-handler-types.html" rel="nofollow">http://docs.aws.amazon.com/lambda/latest/dg/python-programming-model-handler-types.html</a></p>
<p>节选:</p>
<p>在Python中创建处理程序函数时,请使用以下通用语法结构。在</p>
^{pr2}$
<p>在语法中,请注意以下内容:</p>
<ul>
<li>event–AWS Lambda使用此参数将事件数据传递给处理程序。此参数通常为Python dict类型。它也可以是list、str、int、float或NoneType类型。在</li>
<li>上下文–awslambda使用此参数向处理程序提供运行时信息。此参数属于LambdaContext类型。在</li>
<li>处理程序可以选择返回值。返回值的结果取决于调用Lambda函数时使用的调用类型:
如果使用RequestResponse调用类型(同步执行),AWS Lambda将Python函数调用的结果返回给调用Lambda函数的客户机(在对调用请求的HTTP响应中,序列化为JSON)。例如,AWS Lambda控制台使用RequestResponse调用类型,因此当您使用控制台测试调用函数时,控制台将显示返回值。
如果处理程序未返回任何内容,则AWS Lambda将返回null。
如果使用事件调用类型(异步执行),则会丢弃该值。在</li>
</ul>