Pexpect on Windows New in version 4.0: Windows support
Pexpect can be used on Windows to wait for a pattern to be produced by a child process, using pexpect.popen_spawn.PopenSpawn, or a file descriptor, using pexpect.fdpexpect.fdspawn. This should be considered experimental for now.
pexpect.spawn and pexpect.run() are not available on Windows, as they rely on Unix pseudoterminals (ptys). Cross platform code must not use these.
看下面dir的结果,pexpect模块里面没有sendline这个方法,所以会报AttributeError.
正确的用法示例如下:
要在pexpect.spawn(cmd)的返回值上调用sendline方法,参考:http://pexpect.readthedocs.org/en/stable/overview.html
Pexpect on Windows
New in version 4.0: Windows support
Pexpect can be used on Windows to wait for a pattern to be produced by a child process, using pexpect.popen_spawn.PopenSpawn, or a file descriptor, using pexpect.fdpexpect.fdspawn. This should be considered experimental for now.
pexpect.spawn and pexpect.run() are not available on Windows, as they rely on Unix pseudoterminals (ptys). Cross platform code must not use these.