Python模块“spawn”。模块对象不是callab

2024-09-22 18:29:20 发布

您现在位置:Python中文网/ 问答频道 /正文

这是我的代码:

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)

在这里,我尝试使用pexpectspawnSSH到一个框中,但是我的Pycharm总是返回

TypeError: 'module' object is not callable in the bold line


Tags: 代码importchildhosttimeoutusernamepasswordssh
1条回答
网友
1楼 · 发布于 2024-09-22 18:29:20

你这样做是完全错误的,首先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,因为您无法在其他任何地方覆盖它

相关问题 更多 >