燕鹏
před 3 roky
revize
5cdccdc4cf
4 změnil soubory, kde provedl 63 přidání a 0 odebrání
@ -0,0 +1,29 @@ |
|||
<?xml version="1.0" encoding="UTF-8"?> |
|||
<project xmlns="http://maven.apache.org/POM/4.0.0" |
|||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" |
|||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> |
|||
<modelVersion>4.0.0</modelVersion> |
|||
|
|||
<groupId>org.example</groupId> |
|||
<artifactId>java4python</artifactId> |
|||
<version>1.0-SNAPSHOT</version> |
|||
<dependencies> |
|||
<dependency> |
|||
<groupId>org.python</groupId> |
|||
<artifactId>jython-standalone</artifactId> |
|||
<version>2.7.0</version> |
|||
</dependency> |
|||
</dependencies> |
|||
<repositories> |
|||
<repository> |
|||
<id>spring</id> |
|||
<url>https://maven.aliyun.com/repository/public</url> |
|||
<releases> |
|||
<enabled>true</enabled> |
|||
</releases> |
|||
<snapshots> |
|||
<enabled>true</enabled> |
|||
</snapshots> |
|||
</repository> |
|||
</repositories> |
|||
</project> |
@ -0,0 +1,16 @@ |
|||
import org.python.util.PythonInterpreter; |
|||
|
|||
/** |
|||
* @author yanpeng |
|||
* @version 1.0 |
|||
* @desc TODO |
|||
* @company 北京中经网软件有限公司 |
|||
* @date 2021/7/16 17:43 |
|||
*/ |
|||
public class JavaRunPythonCode { |
|||
public static void main(String[] args) { |
|||
PythonInterpreter interpreter = new PythonInterpreter(); |
|||
interpreter.exec("a='hello world'; "); |
|||
interpreter.exec("print a;"); |
|||
} |
|||
} |
@ -0,0 +1,15 @@ |
|||
import org.python.util.PythonInterpreter; |
|||
|
|||
/** |
|||
* @author yanpeng |
|||
* @version 1.0 |
|||
* @desc TODO |
|||
* @company 北京中经网软件有限公司 |
|||
* @date 2021/7/16 17:43 |
|||
*/ |
|||
public class JavaRunPythonFile { |
|||
public static void main(String[] args) { |
|||
PythonInterpreter interpreter = new PythonInterpreter(); |
|||
interpreter.execfile("classpath:/javaPythonFile.py"); |
|||
} |
|||
} |
@ -0,0 +1,3 @@ |
|||
a = 1 |
|||
b = 2 |
|||
print (a + b) |
Načítá se…
Odkázat v novém úkolu