1

我一直在尝试从 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: No module named parser 的错误

有人可以在这里帮助我吗?

4

1 回答 1

1

在 inline python 中检查,他们提供了这样的示例代码:它有效吗?请检查 parser.py 是否在您的 PYTHONPATH 中。

 use Inline Python;

   my $obj = new Myclass;

   __END__
   __Python__

   from mylibrary import myclass as Myclass
于 2012-12-13T10:53:36.937 回答