これは、ボタンのクリック イベントの Java コードです。私がやろうとしているのは、私が呼び出しているpythonファイルにパラメーターを渡すことです...しかし、エラーが発生していますargs[0]
and args[1]
(cannot find symbol
)。
この問題を回避するにはどうすればよいですか? この方法で呼び出している Python ファイルにパラメーターを渡すにはどうすればよいですか?
private void jButton1MouseClicked(java.awt.event.MouseEvent evt) {
try {
PythonInterpreter.initialize(System.getProperties(), System.getProperties(), new String[0]);
PythonInterpreter interp = new PythonInterpreter();
interp.set("firstName", args[0]);
interp.set("lastName", 1);
interp.execfile("C:\\Users\\aswin-pc\\Desktop\\pythontest.py");
}
catch (Exception e) {
e.printStackTrace();
}