【问题标题】:Raspberry pi 2 os.System() command returning 0树莓派 2 os.System() 命令返回 0
【发布时间】:2017-09-17 22:09:41
【问题描述】:

好的,所以我使用树莓派 2 并使用 python 在终端上运行命令。通常我使用 os.system('terminal Command here')。问题是,当我使用 sudo python3 文件名 运行程序时,它会打印我想要的命令,但它也会打印 0。我猜 0 是命令成功运行的标志,但我不希望 0 出现。有什么办法可以摆脱它返回 0

【问题讨论】:

标签: linux python-3.x raspberry-pi os.system


【解决方案1】:

我的代码是:

import os
import sys

print(os.system("sudo arp -a"))

它会打印“Sudo arp -a”命令的输出,但之后它还会在下一行放置一个 0。

【讨论】:

猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2015-09-22
  • 2014-04-29
  • 2020-09-16
相关资源
最近更新 更多