user =input("please enter your user name\n")
passwd1=input("please enter your passwd\n")
ssh = paramiko.SSHClient()
ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
ssh.connect('vlmanutslab1',username=user,password=passwd1)
stdin,stdout,stderr = ssh.exec_command(command1)
output1=stdout.readlines()
stdin,stdout,stderr = ssh.exec_command(command2)
output2=stdout.readlines()
stdin,stdout,stderr = ssh.exec_command(command3)
output3=stdout.readlines()
print( "vlmanutslab1" + " "+ output1 +" " + " " + output2))
如何添加列表和字符串? 我得到的错误,如不能连接字符串和列表在一起。你知道吗
你必须把它转换成字符串
一种方法是使用
"".join()
方法要增加它们之间的空间,可以使用
tab
您拥有的是一个字符串列表,您可以使用内置的^{} method. 将一个字符串列表转换为一个字符串
这里很重要的一点是,您需要调用
join()
一个字符串,以便将字符串与字符串列表作为参数连接在一起。也就是说,字符串被添加到列表中的每一组连续字符串之间(而不是在开始和结束处)。你知道吗如果要换行分隔:
尽管您可以用
"\n"
替换任何您喜欢的字符串。如果要在列表之间用两个空格分隔它们:相关问题 更多 >
编程相关推荐