使用pexpect.spawn,我在后台运行一个程序,为每个发送的输入行发回一行。
将整行作为输出的适当期望表达式是什么?
(在等到输出中的那条线之后)
我不想使用任何特定的字符串(如提示),而不是新行同步。
我尝试myprogram.expect('\r\n')
,但它似乎包含输入和输出。
答案 0 :(得分:0)
I tried myprogram.expect('\r\n'), but it seems to contain the input along with the output.
这是否意味着考虑输入中的“\ n”?如果是,有一种方法可以通过将set echo
设置为false来抑制回声。你可以试试。
你也可以粘贴你正在尝试的代码吗?