亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

如何將列表傳遞到 SNS 的消息中?

如何將列表傳遞到 SNS 的消息中?

森林海 2021-10-12 15:06:56
我正在嘗試使用 python 發送 SNS。它工作正常。但我想將列表傳遞到 SNS 的消息正文中。怎么做?我試過但沒有工作。list = [('9',), ('8',), ('7',), ('6',), ('5',), ('4',), ('3',), ('23',), ('22',), ('21',), ('20',), ('2',), ('19',), ('18',), ('17',), ('16',), ('15',), ('14',), ('13',), ('12',), ('11',), ('10',), ('0',)]message = { "source": "datapipeline",            "application_nm": "omni",            "severity": "2",            "batch_run_start_dttm": "$actualStartTime",            "batch_run_end_dttm": "actualEndTime",            "batch_run_status_cd": "failed",            "job_orchestration_id": "NA",            "stage_nm": "NA",            "stage_start_dttm": "NA",            "stage_end_dttm": "NA",            "stage_status_cd":  "failed",            "job_run_id": "NA",            "source_nm": "NA",            "target_nm": "NA",            "source_details": "NA",            "target_details": "NA",            "msg": "These mentioned hours having difference more than 50% from previous week:" +"%s"  ,            "counts":"0",            "notes": "After hourly comparison check, the above mentioned hours is having difference more than 50%"          } %listtry:    response = client.publish(    TargetArn=sns_arn,    Subject = 'Hourly comaprison mismatch',    Message=json.dumps({'default': json.dumps(message)}),    MessageStructure='json'    )    #return 'servicenow'except Exception as e:    return e    print(e)    print('SNS is throwing error!')試圖通過 %s 傳遞列表值是 msg。但是拋出錯誤。如何將該列表值傳遞到 SNS 的 JSON 格式 msg 正文中?
查看完整描述

1 回答

?
浮云間

TA貢獻1829條經驗 獲得超4個贊

嘗試這個:


message = { "source": "datapipeline",

            "application_nm": "omni",

            "severity": "2",

            "batch_run_start_dttm": "$actualStartTime",

            "batch_run_end_dttm": "actualEndTime",

            "batch_run_status_cd": "failed",

            "job_orchestration_id": "NA",

            "stage_nm": "NA",

            "stage_start_dttm": "NA",

            "stage_end_dttm": "NA",

            "stage_status_cd":  "failed",

            "job_run_id": "NA",

            "source_nm": "NA",

            "target_nm": "NA",

            "source_details": "NA",

            "target_details": "NA",

            "msg": "These mentioned hours having difference more than 50% from previous week:" +"%s"  ,

            "counts":"0",

            "notes": "After hourly comparison check, the above mentioned hours is having difference more than 50%",

            "list": list # this is how to do it

          }

順便說一句,將變量命名為“列表”是一個非常糟糕的主意,它與內置list()函數發生沖突。


查看完整回答
反對 回復 2021-10-12
  • 1 回答
  • 0 關注
  • 209 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號