0
我有一個文檔測試,並且我要救我跑什麼命令到一個變量,在另一個功能節能標準輸出到一個變量在文檔測試
>>> sh("git finish", return_output=True).split("#")[1].split(":")[0]
(here comes an int i want to save, say 900)
的SH使用它是一個命令行功能
output = Popen(["mycmd", "myarg"], stdout=PIPE).communicate()[0]
更多Informa的:這樣看
# short alias for check_output
def sh(cmd, return_output=False):
from subprocess import call
open('/dev/shm/fail_output', 'w').close()
with open('/dev/shm/fail_output', 'a+') as output:
call(cmd, stderr=output, stdout=output, shell=True)
with open('/dev/shm/fail_output', 'r') as output:
if return_output:
return output.read()
print output.read()
return locals()