Java 在Python脚本上实现ExpectJ

Java 在Python脚本上实现ExpectJ,java,python,python-2.7,expect,Java,Python,Python 2.7,Expect,我有一个名为age.py的Python脚本 #!/usr/bin/env python #file: age.py age = raw_input("Enter your age: ") print "Your age in dog years is", float(age)/7 我正在使用Expectj库,这是我正在使用的java代码段 ExpectJ exp = new ExpectJ(); Spawn s = null; try { s = exp.spawn(test1);

我有一个名为age.py的Python脚本

#!/usr/bin/env python
#file: age.py

age = raw_input("Enter your age: ")
print "Your age in dog years is", float(age)/7
我正在使用Expectj库,这是我正在使用的java代码段

ExpectJ exp = new ExpectJ();
Spawn s = null;
try {
    s = exp.spawn(test1);       
    s.expect("Enter your age: ");
    System.out.println("Current status: "+s.getCurrentStandardOutContents());
    s.send("y\n");
} catch (IOException e) {
      // TODO Auto-generated catch block
        e.printStackTrace();
        System.out.println("ioe\n");
} catch (TimeoutException e) {
      // TODO Auto-generated catch block
         e.printStackTrace();
         System.out.println("toe\n");
} finally {
         if (s != null) 
         s.stop();           
}

这不会捕获sysout消息
“输入您的年龄:
”,因此脚本进入无限等待状态。ExpectJ使用python脚本需要什么修复程序?

我不熟悉ExpectJ,但我猜它需要一个以新行结尾的行,这是
原始输入
无法生成的。从:

如果存在提示参数,则将其写入标准输出 没有尾随的换行符


我在比赛中没有换行