如何使用Python4Delphi从Delphi向Python返回列表
使用Python4Delphi,将Delphi方法公开给Python,这样Python就可以调用Delphi应用程序了。但是,我无法将由Delphi方法创建的Python列表返回给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
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方法,当您使用该方法时是否有效?