subprocess.CalledProcessError :没有这样的文件或目录。即使文件存在

tail: cannot open 'home/sourabh/sanju.txt' for reading: No such file or directory


Traceback (most recent call last):

  File "/home/sourabh/resizeWindow.py", line 23, in <module>

    line = subprocess.check_output(['tail', '-1', 'home/sourabh/sanju.txt']).split(' ')[3:]


  File "/usr/lib/python2.7/subprocess.py", line 223, in check_output

    raise CalledProcessError(retcode, cmd, output=output)


subprocess.CalledProcessError: Command '['tail', '-1', 'home/sourabh/sanju.txt']' returned non-zero exit status 1

我已经交叉检查文件是否存在,甚至故意创建了一个文件。


我的python代码中的确切行是:


line = subprocess.check_output(['tail', '-1', 'home/sourabh/sanju.txt']).split(' ')[3:]


森栏
浏览 541回答 1
1回答
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

Python