我想用pexpect使用python中的maxima,每当maxima启动时,它都会打印出以下形式的大量内容:
$ maxima
Maxima 5.27.0 http://maxima.sourceforge.net
using Lisp SBCL 1.0.57-1.fc17
Distributed under the GNU Public License. See the file COPYING.
Dedicated to the memory of William Schelter.
The function bug_report() provides bug reporting information.
(%i1)
我希望像这样启动pexpect:
^{pr2}$如何将起始横幅与提示符(%i1)匹配? 以此类推,随着会话的进行,maxima也会将(%i1)的值增加1
(%i1) integrate(sin(x),x);
(%o1) - cos(x)
(%i2) integrate(log(x),x);
(%o2) x log(x) - x
(%i3)
所以下一个期望是:
child.expect ('match (%i2)')
child.sendline ('integrate(log(x),x)')
child.expect( match (%i3) )
print child.before
如何匹配(递增)整数? 基本上,我需要在打印(%o)时匹配(%i)
此正则表达式与它匹配:}。在
\(%i\d\)
。如果您需要匹配(%o#)
,只需将针中的i
替换为{相关问题 更多 >
编程相关推荐