简体   繁体   中英

AWS SNS Message format using Boto3

I have set up an SNS notification and can successfully send a list into the message as follows:

sns.publish(TopicArn='arn:aws:sns:eu-xxx-x:1234567:my_sns', Message=f"New URLS are {newUrls}")

This gives the following output in the SNS message:

New URLS are [' http://www.123.bar ', ' http://abc.foo ', ' http://foo.bar ']

How do I structure the output to look like this with new lines and no square brackets for the list: (this is a trivial task in Python but I am struggling to do this with the message parameter)

New URLS are:

http://www.123.bar

http://abc.foo

http://foo.bar

I have tried sending a print function into the message parameter but it returns None

This is how I resolved it:

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}")

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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