我试图通过在下面的代码中使用 subprocess 模块来使用 python 运行 shell 命令,但我不明白为什么我的脚本会抛出如下错误。有人可以帮助我我所缺少的吗?
Traceback (most recent call last):
File "/Scripts/test_file.py", line 6, in <module>
p2 = subprocess.Popen('sed s\'/"/ /g\'', stdin=p1.stdout, stdout=subprocess.PIPE)
File "/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.8/lib/python3.8/subprocess.py", line 854, in __init__
self._execute_child(args, executable, preexec_fn, close_fds,
File "/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.8/lib/python3.8/subprocess.py", line 1702, in _execute_child
raise child_exception_type(errno_num, err_msg, err_filename)
FileNotFoundError: [Errno 2] No such file or directory: "sed s'/"/ /g'"`
Run Code Online (Sandbox Code Playgroud)
import subprocess
#output3.txt='/Users/boggulv/Desktop/output3.txt'
p1 = subprocess.Popen( ['cat', 'output3.txt'], stdout=subprocess.PIPE)
print(p1)
p2 = subprocess.Popen('sed s\'/"/ /g\'', stdin=p1.stdout, stdout=subprocess.PIPE)
p3 = subprocess.Popen('grep "sO"', stdin=p2.stdout,stdout=subprocess.PIPE)
p4 = …Run Code Online (Sandbox Code Playgroud)