添加链接
link管理
链接快照平台
  • 输入网页链接,自动生成快照
  • 标签化管理网页链接
相关文章推荐
性感的仙人掌  ·  Jest Testing like a ...·  21 小时前    · 
憨厚的课本  ·  权威发布 | ...·  2 月前    · 
性感的人字拖  ·  GitHub - ...·  5 月前    · 
火星上的羽毛球  ·  【Python ...·  1 年前    · 

Wexpect is a Windows variant of Pexpect Wexpect and Pexpect makes Python a better tool for controlling other applications.

Wexpect is a Python module for spawning child applications; controlling them; and responding to expected patterns in their output. Wexpect works like Don Libes’ Expect. Wexpect allows your script to spawn a child application and control it as if a human were typing commands.

Wexpect can be used for automating interactive applications such as ssh, ftp, passwd, telnet, etc. It can be used to a automate setup scripts for duplicating software package installations on different servers. It can be used for automated software testing. Wexpect highly depends on Mark Hammond’s pywin32 which provides access to many of the Windows APIs from Python.

Install

Wexpect is on PyPI, and can be installed with standard tools:

pip install wexpect

To interract with a child process use spawn method:

import wexpect
child = wexpect.spawn('cmd.exe')
child.expect('>')
child.sendline('ls')
child.expect('>')
print(child.before)
child.sendline('exit')

For more information see examples folder.

Contents:

  • API documentation
  •