使用 Boto3 的 AWS SNS 消息格式
AWS SNS Message format using Boto3
我设置了SNS通知,可以成功发送列表到消息如下:
sns.publish(TopicArn='arn:aws:sns:eu-xxx-x:1234567:my_sns', Message=f"New URLS are {newUrls}")
这会在 SNS 消息中提供以下输出:
新 URL 为 ['http://www.123.bar', 'http://abc.foo', 'http://foo.bar']
如何将输出结构化为如下所示,使用新行且列表没有方括号:
(这是 Python 中的一项微不足道的任务,但我正在努力使用消息参数来完成此任务)
新网址是:
我已经尝试将打印函数发送到消息参数中,但它 returns None
我是这样解决的:
newUrlsString = "\n".join(newUrls)
nl = "\n"
sns.publish(TopicArn='arn:aws:sns:eu-xxx-x:1234567:my_sns', Message=f"New URLS are: {nl+newUrlsString}")
我设置了SNS通知,可以成功发送列表到消息如下:
sns.publish(TopicArn='arn:aws:sns:eu-xxx-x:1234567:my_sns', Message=f"New URLS are {newUrls}")
这会在 SNS 消息中提供以下输出:
新 URL 为 ['http://www.123.bar', 'http://abc.foo', 'http://foo.bar']
如何将输出结构化为如下所示,使用新行且列表没有方括号: (这是 Python 中的一项微不足道的任务,但我正在努力使用消息参数来完成此任务)
新网址是:
我已经尝试将打印函数发送到消息参数中,但它 returns None
我是这样解决的:
newUrlsString = "\n".join(newUrls)
nl = "\n"
sns.publish(TopicArn='arn:aws:sns:eu-xxx-x:1234567:my_sns', Message=f"New URLS are: {nl+newUrlsString}")