Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/python-3.x/17.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/amazon-web-services/13.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 3.x 带分号的boto3变量_Python 3.x_Amazon Web Services_Aws Lambda_Boto3 - Fatal编程技术网

Python 3.x 带分号的boto3变量

Python 3.x 带分号的boto3变量,python-3.x,amazon-web-services,aws-lambda,boto3,Python 3.x,Amazon Web Services,Aws Lambda,Boto3,我有一个向用户发送电子邮件的脚本。请查找以下示例: **Variable1 = test1@gmail.com;test2@gmail.com** **Variable2 = source@gmail.com** **Variable3 = destination@gmail.com** **response = ses.send_email(Source=[ Variable2 ], Destination={'ToAddresses': [ Variable1 ],'BccAddres

我有一个向用户发送电子邮件的脚本。请查找以下示例:

**Variable1 = test1@gmail.com;test2@gmail.com**

**Variable2 = source@gmail.com**

**Variable3 = destination@gmail.com**

**response = ses.send_email(Source=[ Variable2 ], Destination={'ToAddresses': [ Variable1 ],'BccAddresses': [ Variable3 ]}, Message = message)**
“errorMessage”:“调用SendEmail操作时发生错误(InvalidParameterValue):非法分号,不在组中”


Variable1是实例中的电子邮件标记,有时有多封电子邮件以分号分隔。

您可以像下面这样拆分和筛选出有效的电子邮件地址:

email_ids = list(filter(None, email_ids.split(";")))

将分号分隔的字符串拆分为地址列表…?!而不是将包含分号分隔地址的字符串的列表作为
toaddress
传递…?!在一个测试用例中,当只有一个电子邮件地址以分号结尾时,我尝试了拆分(test1@gmail.com;),它为第二个空白电子邮件地址提供了一个错误。现在,我只运行第一个电子邮件地址,如变量ab1(0),如果你有一个地址以分号结尾,你需要仔细考虑这个情况。例如,
trim
将分号从末尾去掉,然后拆分。或拆分,然后从列表中筛选出空字符串。