From: paolo <pl...@ka...> - 2008-02-15 19:28:51
|
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> </head> <body bgcolor="#ffffff" text="#000000"> <font face="Times New Roman, Times, serif">Hi,<br> this is my Python script<br> <br> prova.py<br> -------------------------------------<br> import sys<br> import getopt<br> <br> def main():<br> print "CIAO...."<br> # parse command line options<br> try:<br> opts, args = getopt.getopt(sys.argv[1:], "h", ["help"])<br> except getopt.error, msg:<br> print msg<br> print "for help use --help"<br> sys.exit(2)<br> # process options<br> for o, a in opts:<br> if o in ("-h", "--help"):<br> print "AIUTO"<br> sys.exit(0)<br> # process arguments<br> for arg in args:<br> print "NON definito" # process() is defined elsewhere<br> <br> if __name__ == "__main__":<br> main()<br> -----------------------------------------------------<br> <br> And this is my java code<br> <br> Prova.java<br> -----------------------------------------------------<br> import org.python.util.PythonInterpreter;<br> import java.io.*;<br> <br> public class Prova {<br> <br> /**<br> * @param args<br> */<br> public static void main(String[] args) {<br> // TODO Auto-generated method stub<br> PythonInterpreter interprete = new PythonInterpreter();<br> Writer out = new StringWriter();<br> Writer err = new StringWriter();<br> interprete.setErr(err);<br> interprete.setOut(out);<br> System.out.println("Avvio");<br> interprete.execfile("prova.py");<br> System.out.println(out);<br> System.out.println(err);<br> System.out.println("Fine");<br> }<br> <br> }<br> -----------------------------------------------------------<br> <br> why Prova.py no print Standard output/error ???? <br> </font> <pre class="moz-signature" cols="72"> </pre> </body> </html> |