提问人:Komal 提问时间:10/11/2023 最后编辑:Arnab NandyKomal 更新时间:10/12/2023 访问量:46
换行符在 pymsteams 文本中不起作用
New line characters not working in pymsteams text
问:
我从 Linux 机器上获得了以下输出,我正在尝试将其推送到 MS Teams 频道。但是,当文本显示在团队频道中时,输出格式会发生变化。换行符不起作用。
stdin, stdout, stderr = client.exec_command("ip addr | grep bond0")
pwd_out=stdout.read().decode("utf-8")
new_text="Link Status:"+"\n" + pwd_out
print(new_text)
myTeamsMessage.text(new_text)
Python 终端输出:
`> Link Status:
6: ens1f0: <BROADCAST,MULTICAST,SLAVE,UP,LOWER_UP> mtu 1500 qdisc mq master bond0 state UP group default qlen 1000
9: ens2f1: <BROADCAST,MULTICAST,SLAVE,UP,LOWER_UP> mtu 1500 qdisc mq master bond0 state UP group default qlen 1000
10: bond0: <BROADCAST,MULTICAST,MASTER,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP group default qlen 1000
11: bond0.400@bond0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP group default qlen 1000
inet 192.168.40.10/24 brd 192.168.40.255 scope global noprefixroute bond0.400
12: bond0.501@bond0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP group default qlen 1000
inet 192.168.51.16/24 brd 192.168.51.255 scope global noprefixroute bond0.501`
MSTEAMS输出:
payload: {'text': 'Link Status:\n6: ens1f0: <BROADCAST,MULTICAST,SLAVE,UP,LOWER_UP> mtu 1500 qdisc mq master bond0 state UP group default qlen 1000\n9: ens2f1: <BROADCAST,MULTICAST,SLAVE,UP,LOWER_UP> mtu 1500 qdisc mq master bond0 state UP group default qlen 1000\n10: bond0: <BROADCAST,MULTICAST,MASTER,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP group default qlen 1000\n11: bond0.400@bond0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP group default qlen 1000\n inet 192.168.40.10/24 brd 192.168.40.255 scope global noprefixroute bond0.400\n12: bond0.501@bond0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP group default qlen 1000\n inet 192.168.51.16/24 brd 192.168.51.255 scope global noprefixroute bond0.501\n'}
有没有办法让 MS 团队的输出与 Python 终端输出相同?
答: 暂无答案
评论
new_text="Link Status:"+"\r\n" + pwd_out