Can't find module re

本文介绍如何在Jython中集成Python模块,并提供在Java代码中设置Python模块路径的方法。此外,还讨论了Jython支持的标准Python库范围,包括哪些内置模块已移植到Jython及其使用限制。

You embed jython and you will use some Python-Modules somewere:

if you want to set the path (sys.path) in your Java-Code :

public void init() { 
        interp
= new PythonInterpreter(null, new PySystemState()); 
 
       
PySystemState sys = Py.getSystemState(); 
        sys
.path.append(new PyString(rootPath)); 
        sys
.path.append(new PyString(modulesDir)); 
   
} 

Py is in org.python.core.

rootPath and modulesDir is where YOU want !

let rootPath point where you located the standard-jython-lib

Have a look at src/org/python/util/PyServlet.java in the Jython-Source-Code for example

 

 

4.1 What parts of the Python library are supported?

The good news is that Jython now supports a large majority of the standard Python library. The bad news is that this has moved so rapidly, it's hard to keep the documentation up to date.

Built-in modules (e.g. those that are written in C for CPython) are a different story. These would have to be ported to Java, or implemented with a JNI bridge in order to be used by Jython. Some built-in modules have been ported to JPython, most notably cStringIO, cPickle, struct, and binascii. It is unlikely that JNI modules will be included in Jython proper though.

If you want to use a standard Python module, just try importing it. If that works, you're probably all set. You can also do a dir() on the modules to check the list of functions it implements.

If there is some standard Python module that you have a real need for that doesn't work with Jython yet, please send us mail.

 

You can use pure python modules from jython. You can't use modules that are implemented in C. re and HTMLParser are delivered with jython
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值