java调用jython时的中文问题,急呀

fuyingch fuyingch 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区
test.py代码如下,非常简单
# -*- coding: utf-8 -*-
s = "中文"
print s

java代码如下,ExePythonFile.java
import org.python.util.PythonInterpreter;
public class ExePythonFile {
public static void main(String[] args) {
PythonInterpreter interp = new PythonInterpreter();
interp.execfile("D:/eclipse_platform_workspace/java/test.py");
}
}
运行ExePythonFile 时输出是乱码“涓枃”,请教给我应该怎么弄才能正确输入中文,py文件中我已经写了utf-8编码的。
...全文
评论 4
收藏 已收藏
分享
返回顶部
fuyingch
Java SE 62,621 成员 307,251 内容