MATLAB 捕获由 Python 抛出的异常并传递给一个 matlab.exception.PyException 对象。该对象是由 MException 中派生的。
try
py.list('x','y',1)
catch e
e.message
if(isa(e,'matlab.exception.PyException'))
e.ExceptionObject
end
end
结果:
ans =
Python Error: TypeError: list() takes at most 1 argument (3 given)
ans =
Python tuple with no properties.
(<type 'exceptions.TypeError'>, TypeError('list() takes at most 1 argument (3 given)',), None)
如果 MATLAB 显示下列格式的错误信息,请参阅 Python 文档。
Python Error: Python class: message
参考资料:
1.MATLAB 官方文档:https://ww2.mathworks.cn/help/