Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/opencv/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何使用Python4Delphi从Delphi向Python返回列表_Delphi_Python4delphi - Fatal编程技术网

如何使用Python4Delphi从Delphi向Python返回列表

如何使用Python4Delphi从Delphi向Python返回列表,delphi,python4delphi,Delphi,Python4delphi,使用Python4Delphi,将Delphi方法公开给Python,这样Python就可以调用Delphi应用程序了。但是,我无法将由Delphi方法创建的Python列表返回给Python。例如: function TDelphiAPI.callMethod : PPyObject; begin // Create a new empty list of three elements result := GetPythonEngine.PyList_New(3); end; imp

使用Python4Delphi,将Delphi方法公开给Python,这样Python就可以调用Delphi应用程序了。但是,我无法将由Delphi方法创建的Python列表返回给Python。例如:

function TDelphiAPI.callMethod : PPyObject;
begin
  // Create a new empty list of three elements
  result := GetPythonEngine.PyList_New(3);
end;

import mylib
p = mylib.DelphiAPI()
print p.callmethod()
当从Python调用时,返回'NoneType'。如果将PPyObject更改为integer、AnsiString或double等类型,Python将选择正确的类型并正确显示它。我用

  GetPythonEngine.AddMethod ('callMethod', @TDelphiAPI.callMethod, 'callMmethod)');
从Delphi公开该方法。但是,据我所知,无法为参数或返回类型指定类型


我想知道是否有人从delphi python类型(如列表或甚至numpy数组)返回过?

TpyTonEngine似乎有一个ArrayToPyList方法,当您使用该方法时是否有效?