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)