简体   繁体   English

如何在 python 中获取 AWS lambda 中的用户输入

[英]How to take user input in AWS lambda in python

I want to take length of an array 'n' and elements of array 'a[]' as input from user and want to sort that array in AWS lambda function. But I don't know how to take user input in AWS lambda.我想将数组“n”的长度和数组“a[]”的元素作为用户输入,并希望在 AWS lambda function 中对该数组进行排序。但我不知道如何在 AWS lambda 中获取用户输入。

In your lambda_handler function, that AWS automatically creates for you, you will be getting Event and Context在 AWS 自动为您创建的 lambda_handler function 中,您将获得事件和上下文

You want to use the Event to access variables passed to your function.您想要使用 Event 访问传递给您的 function 的变量。

For example:例如:

def lambda_handler(event, context):
    arrayPassedToFunction = event['yourArray']

The Event is a JSON like object hence why you can access each key in the event with ['key']事件是一个 JSON 就像 object 因此为什么你可以使用 ['key'] 访问事件中的每个键

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM