Python subprocess.Popen 调用的 exe 文件没有成功运行结束
我先写了一个 C++ 的程序
#include <bits/stdc++.h>
using namespace std;
int main() {
int n;
scanf("%d",&n);
printf("%d",n);
return 0;
}
然后成功将其编译成 exe
手动在命令行调用 "F:\\Online_Judge\\static\\code\\1" <"F:\\Online_Judge\\static\\Problems\\P1000 Online Judge 试机题目\\test_points\\1.in" >"F:\\Online_Judge\\static\\code\\1_1.out"
(保证文件存在且可以正常调用,并且权限足够)
可以成功运行,将 1.in 中的数据读入并写到 1_1.out 中,用 Python 运行以下代码 subprocess.Popen(['F:\\Online_Judge\\static\\code\\1', '<F:\\Online_Judge\\static\\Problems\\P1000 Online Judge 试机题目\\test_points\\1.in', '>F:\\Online_Judge\\static\\code\\1_1.out'])
使用列表传参的方式运行命令行,但是该 exe 并没有成功运行结束,在 cmd 的 tasklist 中可看见 exe 卡住了
Python 使用 subprocess.Popen 调用 exe 文件后,exe 文件卡住没有成功运行结束,请问这是什么原因?
因为重定向的
<
>
都不是参数。不能用参数的方式传递。大概的这么写(没测):
Popen