python 3中 的subprocess

commands好像python3.6被去除了,它现在被subprocess替代了

FUNCTIONS
    getoutput(cmd)
        Return output (stdout or stderr) of executing cmd in a shell.

    getstatus(file)
        Return output of "ls -ld <file>" in a string.

    getstatusoutput(cmd)
        Return (status, output) of executing cmd in a shell.



import subprocess

(status, output) = subprocess.getstatusoutput('redis-cli -h 127.0.0.1 -p 6379 -n 0 keys *')
print (status, output)

 

posted @ 2018-12-03 18:03  Gaoyongxian666  阅读(199)  评论(0编辑  收藏  举报