【发布时间】:2013-10-03 18:41:10
【问题描述】:
我有一个通常从终端运行的命令(Say foo),如下所示:
user@computer$ foo
enter the string: *(here I enter some string)*
RESULT OF THE COMMAND WITH THE GIVEN INPUT
我事先知道我需要提供什么意见。那么,如何使用此 python 代码自动调用:
from subprocess import call
call(['foo'])
如何自动输入 foo ?
【问题讨论】:
-
call([input('Enter the string')])在 Python 3.x 中,或call([raw_input()])在 Python 2.x 中 -
这与 foo 无关。我怎么称呼它?
-
@user1928721 不要使用上面评论中的方法。这不是你想要的。
标签: python process subprocess