我正在使用位于 https://github.com/catalyst/smokeping-mtr-alert/blob/master/smokeping-mtr-alert 的脚本中的 python 代码在 Linux 上执行 MTR 实现.
我关心的代码行是
mtr_command = "mtr -n --report %s" % pipes.quote(args.hostname)
我希望使用 -o
选项修改 mtr 的输出以提供我想要的详细信息,特别是我想添加 -o "LSRD NBWA JXIM V"
但显然代码不能
mtr_command = "mtr -n --report %s -o "LSRD NBWA JXIM V" % pipes.quote(args.hostname)
如何添加我的输出修饰符以获得我需要的输出?
最佳答案
mtr_command = 'mtr -n --report %s -o "LSRD NBWA JXIM V"'% pipes.quote(args.hostname)
或
mtr_command = 'mtr -n --report {0} -o "LSRD NBWA JXIM V"'.format(pipes.quote(args.hostname))
尝试在外部命令字符串上使用单引号,在内部使用双引号
关于python - 地铁 python 和 linux,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49015389/