【发布时间】:2018-03-04 13:24:51
【问题描述】:
我想从 python 脚本运行终端命令。我知道我可以使用os.system() 通话。但这里的问题是,当我运行第一个命令时,我得到一个提示,我必须在其中编写下一个终端命令。例如:-
./distance vectors_bow.bin
Enter word or sentence (EXIT to break): EXIT
我尝试使用os.system('./distance vectors_bow.bin & EXIT')
但我得到输出sh: 1: EXIT: not found。
当我在终端中手动执行上述过程而不是从 python 脚本中时,它工作正常。怎么做?
【问题讨论】:
-
尝试以同样的方式运行命令,即
distance->./distance -
抱歉有问题。你现在能告诉我吗
标签: python shell subprocess system