linux shell setup mysql 有提示字符拼装的GUI输入如下:
pexpect 使用要求移动光标,确认使用 tab 和 回车 key。
测试了一下,使用
m.expect("password.*root", timeout= -1)
35 m.send("password")
36 time.sleep(0.01)
37 m.send('\033[B') # down
38 time.sleep(0.01)
39 m.send('\r\n') #回车换行符
参考:
https://stackoverflow.com/questions/29217645/pexpect-and-sending-an-enter-key-issues
https://stackoverflow.com/questions/29217645/pexpect-and-sending-an-enter-key-issues
https://stackoverflow.com/questions/12981982/pexpect-send-cursor-movement

没有评论:
发表评论