First of all, Baidu has a few methods 1, with Jython in a jar package, Jython.jar, which encapsulates a special call Python class, but do not know why I use Java a call on the error, so give up. 2. Use Runtime.getruntime (). EXEC (' python filename ') process to execute Python files, but because your computer has both Python2 installed and Python3 installed, and Python2 is the default call, So runtime execution by default with Python2 run, and I am writing with Python3 code, so it does not work 3, because in the DOS command line interface can switch the work path directly to the Python3 installation directory, and then run the Python3 program, So write a bat batch file to switch directories and run the Python3 file, and then use the Java runtime to invoke the bat batch file, it is important to note that because the Python3 installation directory and Python3 code files in the same directory, So the path in the code needs to use the absolute path, at this point, solve the problem.
A series of problems and solutions that Java calls Python