擅长:python、mysql、java
<p>不完全是您想要的,但是您可以检查这两个线程,了解如何从python和c++PLS libs实现调用本机(c/c++代码):</p>
<p><a href="https://stackoverflow.com/questions/11467321/partial-least-squares-library">Partial Least Squares Library</a></p>
<p><a href="https://stackoverflow.com/questions/145270/calling-c-c-from-python">Calling C/C++ from python?</a></p>
<p>您可以使用<a href="http://www.boost.org/doc/libs/1_54_0/libs/python/doc/tutorial/doc/html/index.html" rel="nofollow noreferrer">boost.python</a>将c++代码嵌入到python中。以下是从<a href="http://www.boost.org/doc/libs/1_54_0/libs/python/doc/tutorial/doc/html/index.html" rel="nofollow noreferrer">official site</a>中获取的示例:</p>
遵循C/C++传统,让我们从“你好,世界”开始。一个C++函数:</p>
<pre><code>char const* greet()
{
return "hello, world";
}
</code></pre>
<p>可以通过编写Boost.Python包装器向Python公开:</p>
<pre><code>#include <boost/python.hpp>
BOOST_PYTHON_MODULE(hello_ext)
{
using namespace boost::python;
def("greet", greet);
}
</code></pre>
<p>就这样。我们完了。我们现在可以将其构建为共享库。生成的DLL现在对Python可见。下面是一个示例Python会话:</p>
<pre><code>>>> import hello_ext
>>> print hello_ext.greet()
hello, world
</code></pre>