在使用API Gateway和Lambda的场景中,Lambda函数的打印输出会被发送到CloudWatch日志中。您可以通过以下步骤来查看Lambda函数的打印输出:
以下是一个示例Lambda函数的代码,它在执行时会打印一条消息:
import json
def lambda_handler(event, context):
print("Hello, this is my print output!")
# 其他的Lambda代码
return {
'statusCode': 200,
'body': json.dumps('Lambda function executed successfully')
}
当您在API Gateway中调用该Lambda函数时,该函数的打印输出将被发送到CloudWatch日志中。您可以按照上述步骤查看并检查该打印输出。