编程语言
首页 > 编程语言> > python – pexpect发送光标移动

python – pexpect发送光标移动

作者:互联网

如何使用pexpect发送上,下,左,右键等光标移动.下面的示例是自动化elinks,它使用向上/向下键选择页面上的不同链接.

from pexpect import spawn
child = spawn('elinks http://python.org')
#what goes here to send down key
child.interact()

解决方法:

怎么样使用转义序列up(^ [[A]或down(^ [[B]像这样.

child.send("\033[A")  # up
child.send("\033[B")  # down

标签:pexpect,python
来源: https://codeday.me/bug/20190725/1537034.html