如果我有这样的命令行:
abc -c config.json| xyz -c test.json
如何在Python文件中运行它?我的意思是我们不会在终端中键入“ abc -c config.json| xyz -c test.json
”。
xyz
和abc
是我编写的应用程序。
那么,我可以帮忙吗?
答案 0 :(得分:1)
您可以使用此
os.system("abc -c config.json| xyz -c test.json")
这就像在命令提示符下运行abc -c config.json| xyz -c test.json
。
答案 1 :(得分:0)
您的问题让我有些困惑。
如果要从python中进行系统调用,则可以使用子流程模块
x = subprocess.Popen("ls /home", shell=True, stdout=subprocess.PIPE).stdout.read()
如果要从命令行运行python命令,可以将其写入文件并执行
python myFile.py
或者,直接将命令运行到python
python -c "print("testing")"