Python subprocess.Popen() error (No such file or directory)

前端 未结 2 2052
误落风尘
误落风尘 2020-12-11 00:28

I am trying to count the number of lines in a file using Python functions. Within the current directory, while os.system(\"ls\") finds the file, the command

2条回答
  •  北海茫月
    2020-12-11 01:03

    The error occurs because you are trying to run a command named wc -l sorted_list.dat, that is, it is trying to find a file named like "/usr/bin/wc -l sorted dat".

    Split your arguments:

    ["wc", "-l", "sorted_list.dat"]
    

提交回复
热议问题