Python 模块 'spawn'。模块对象不可调用



这是我的代码:

import pexpect
import spawn
host = 'xx.xx.xx.xx'
userName = 'akshay'
password = 'xxxxxxxxxxxxxx'
**child = spawn('ssh %s@%s' %(userName, host))**
child.setwinsize(1000,200)
child.expect(['password'], timeout=5)

在这里,我尝试使用 pexpectspawn SSH 进入一个盒子,但我的 Pycharm 总是返回

类型错误:"模块"对象在粗体行中不可调用

你完全错了,首先 spawn 不是你需要导入的模块

这是代码:

import pexpect
host = 'xx.xx.xx.xx'
userName = 'akshay'
password = 'xxxxxxxxxxxxxx'
child = pexpect.spawn('command here',timeout=5)
child.setwinsize(1000,200)
child.expect('password')

始终在 pexpect.spawn 中定义超时,因为您无法在其他任何地方覆盖它

最新更新