我有3个文件都在同一个目录下:
- Ex.awk
- Data.csv
- File.py
我想使用子进程来执行我的awk文件,这样将来我就可以在一个PyTest测试用例中调用它.以下是我的示例文件:
Ex.awk
#!/usr/bin/awk -f
BEGIN {
FS = ",";
}
{
print NF;
}
END {print "DONE"}
Data.csv
10,34,32
4,76,8304
4759,5869,2940
File.py
import subprocess
cmd = ['awk', '-f', 'Ex.awk', 'Data.csv']
subprocess.run(cmd)
在bash上,以下命令起作用:
$ awk -f Ex.awk Data.csv
3
3
3
DONE
I'm trying to get the same result when running File.py, but I get the following
FileNotFoundError: [WinError 2] The system cannot find the file specified
个
我的数组中是否缺少一些参数?我是否需要使用其他一些子进程参数,如shell
或其他?