我試圖測試python並使用這個命令。 Iam試圖模擬下面的命令行。在python上測試grep -r使用子進程.Popen
grep -r "any string" . -B1 or grep -r --include=*.xml "any string" -B1
#!/usr/bin/env python
import subprocess
#subprocess.call("ls -l", shell=True)
message_type = raw_input('Enter Something:')
print'"{}"'.format(message_type)
subprocess.Popen(['grep -r', message_type, '.', '-B1'], shell=True)
這是什麼問題? – ZenOfPython
它的工作現在我對待grep -r作爲一個我應該分開它並切換shell = False – nubianz