我正在使用subprocess.check_output向slack發送消息。格式是一團糟,我正在考慮嘗試markdown == false,但只希望它爲每個模塊設置,並且我不確定如何執行此操作。我不知道是否會雖然解決我的問題,更大的問題是如何格式化以下文本是可讀格式化從Errbot發送的Slack消息
應該像(或接近):
代碼:
@botcmd
def find_vm(self, args, SearchString):
output = subprocess.check_output(["C:\\WINDOWS\\system32\\WindowsPowerShell\\v1.0\\powershell.exe", ". \"C:\\Program Files\\Toolbox\\PowerShell Modules\\vmware\\./vmware.psm1\";", "find-vm", SearchString])
return output
正則表達式可以在這裏幫助:https://docs.python.org/3/library/re.html。 你有一個模式「text:text」,其間有空格。 – elena