我要运行的 shell 命令,它什么都不返回:
echo helloWorld | grep 'dummy'
铅版:
以下线路工作:
out=(echo["helloWorld"] | grep["h"])().strip()
但是下一行没有,可能是什么原因?
out=(echo["helloWorld"] | grep["dummy"])().strip()
print(out)
我遇到的错误:
Traceback (most recent call last):
File "dd.py", line 6, in <module>
out=(echo["helloWorld"] | grep["dummy"])().strip()
File "/home/user/venv/lib/python3.5/site-packages/plumbum/commands/base.py", line 103, in __call__
return self.run(args, **kwargs)[1]
File "/home/user/venv/lib/python3.5/site-packages/plumbum/commands/base.py", line 240, in run
return p.run()
File "/home/user/venv/lib/python3.5/site-packages/plumbum/commands/base.py", line 201, in runner
return run_proc(p, retcode, timeout)
File "/home/user/venv/lib/python3.5/site-packages/plumbum/commands/processes.py", line 232, in run_proc
return _check_process(proc, retcode, timeout, stdout, stderr)
File "/home/user/venv/lib/python3.5/site-packages/plumbum/commands/processes.py", line 23, in _check_process
proc.verify(retcode, timeout, stdout, stderr)
File "/home/user/venv/lib/python3.5/site-packages/plumbum/commands/base.py", line 412, in verify
dstproc_verify(retcode, timeout, stdout, stderr)
File "/home/user/venv/lib/python3.5/site-packages/plumbum/machines/base.py", line 26, in verify
stderr)
plumbum.commands.processes.ProcessExecutionError: Command line: ['/bin/grep', 'dummy']
Exit code: 1
[Q]我该如何解决这个错误?