如果要将输出捕获到变量,请使用
subprocess
. 如果不是,你可以使用
os.system
如用户803422所述
import os, subprocess
path = '~/.ssh/authorized_keys'
cmd = 'cat ' + os.path.expanduser(path)
output = subprocess.Popen(cmd.split(), stdout=subprocess.PIPE)
response = output.communicate()
print (response)