def GetTestFile():
sshConn = paramiko.SSHClient()
sshConn.load_system_host_keys()
sshConn.connect(host, port, usrnm, pwrd)
(connin, out, err) = sshObj.exec_command("cat test.txt")
print out.readlines()
lines = []
for i in out.readlines():
lines = lines.append(i)
print lines
print "Lines: ", lines
sshConn.close()
如您所知,这会在远程服务器上执行简单的cat。我想将输出的内容传输到行,但是当它输出为[]时(我检查了for循环似乎没有因某些奇怪的原因被执行)
答案 0 :(得分:1)
list.append
方法不返回列表,它是就地附加。你想要
for i in out.readlines():
lines.append(i)
print lines