我一直在尝试从 Perl 调用 python 类的方法,如下所示
解析器.py
Class ABC(object):
def __init__(self, input_file, output_file):
....
def method1(self):
....
我想从 Perl 脚本调用此方法 abc。逻辑是
obj = ABC(input_file, output_file)
obj. method1()
在 Perl 中尝试了类似下面的方法,但没有成功
use Inline Python => <<"END_OF_PYTHON_CODE";
from parser import ABC
END_OF_PYTHON_CODE
它抛出错误:ImportError:没有名为解析器的模块
有人可以帮我吗?
最佳答案
在内联 python 中检查,他们提供了这样的示例代码:它有效吗? 请检查 parser.py 是否在您的 PYTHONPATH 中。
use Inline Python;
my $obj = new Myclass;
__END__
__Python__
from mylibrary import myclass as Myclass
关于python - 从 perl 调用 python 方法,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13858158/