【发布时间】:2021-09-28 14:08:13
【问题描述】:
我正在尝试使用 python 脚本向 Slack 频道发送消息。消息被传递到松弛通道,但是我看到下一个的格式不正确。
下面给出的是我的数据框,但是当它被发送到松弛通道时,文本没有正确对齐。
name, sales_prct,return_prct
product_id_1234567, 45%, 2%
product_id_45764333, 65%, 12%
product_id_675335, 42%, 7%
【问题讨论】:
-
在文本的开头和结尾使用“```”(三重反引号)。例如:```这是文本。```
-
@Kaushal28 感谢您的回复。我正在使用如下的 f 字符串
message = f'''Hello, given below is the summary {df}''' -
你在 python 中使用它,所以它是一个 python 多行字符串,但它不会像你的松弛通道那样发送。试试这个:
message = f"Hello, given below is the summary ```{df}```"。另外,您使用的是三重单引号,而不是反引号。