0

我试过

>>> import subprocess
>>> import os
>>> subprocess.call(["echo","Hello there"], env=os.environ)
Hello there
0
>>> subprocess.call(["nice", "19", "echo","Hello there"], env=os.environ)
nice: 19: No such file or directory
127
>>> subprocess.call(["nice", "19", "echo","Hello there"], env=os.environ, shell=True)
0
0
>>>

我不明白为什么 subprocess 不能识别nice

我的外壳运行良好没有问题

$nice -n 19 echo '你好'

你好呀

4

1 回答 1

1

看起来您"-n"subprocess.call通话中忘记了与的争论。你可能是说

subprocess.call(["nice", "-n", "19", "echo", "Hello there"], env=os.environ)
于 2013-10-24T06:30:39.010 回答