Python boto send_email lambda SES-预期为缩进的块[关闭]

问题描述 投票:-2回答:1
我正在尝试使用python boto3库通过AWS SES发送电子邮件。但是我在“ response = client.send_email(“行中得到了“预期的缩进块”

def sendEmail(event): data = json.loads(event.body) client = boto3.client('ses',region_name="us-east-1") try: response = client.send_email( Destination={'ToAddresses': ['[email protected]',],}, Message={ 'Body': {'Html': {'Charset': 'UTF-8','Data': 'test',},}, 'Subject': {'Charset': 'UTF-8','Data': 'test',},}, Source='[email protected]', )

响应:{“ errorMessage”:“模块'forms'中的语法错误:期望缩进的块(forms.py,第35行)“,” errorType“:“ Runtime.UserCodeSyntaxError”,“ stackTrace”:[“ File \” / var / task / forms.py \“第35行\ n response = client.send_email(\ n”]}
python amazon-web-services boto3 boto amazon-ses
1个回答
0
投票
代码中有一些多余的空格。试试这个吗?

def sendEmail(event): data = json.loads(event.body) client = boto3.client('ses',region_name="us-east-1") try: response = client.send_email( Destination={'ToAddresses': ['[email protected]',],}, Message={ 'Body': {'Html': {'Charset': 'UTF-8','Data': 'test',},}, 'Subject': {'Charset': 'UTF-8','Data': 'test',},}, Source='[email protected]' )

[在IDE中使用像py-lint这样的短绒棉对我超级有帮助,或者像https://repl.it/languages/python3之类的东西用于快速python env。
© www.soinside.com 2019 - 2024. All rights reserved.