boost 1.34 终于简化了内嵌python的支持
2007-05-23 12:55
399 查看
boost 1.34 终于简化了内嵌python的支持。
还支持了python2.5。
在中文windows下用vc8编译boost的过程中,虽然仍有代码页字符警告,但是可以正常编译成功,不再象1.33.1那样造成正则表达式库不修改源码不能够编译通过的问题了。
下面的例子是从boost文档中来的:
#include <iostream>
#include <string>
#include <boost/python.hpp>
#include <boost/ref.hpp>
#include <vector>
using namespace boost::python;
void greet()
{
object main = import("__main__");
object global(main.attr("__dict__"));
// Define greet function in Python.
object result = exec(
"def greet(a): \n"
" return 'Hello %s from Python!' % a \n",
global, global);
object greet = global["greet"];
list lst;
lst.append(1);
lst.append(2);
object r = greet(lst);
std::string message = extract<std::string>(r);
std::cout << message << std::endl;
}
int _tmain(int argc, _TCHAR* argv[])
{
Py_Initialize();
greet();
system("Pause");
return 0;
}
还支持了python2.5。
在中文windows下用vc8编译boost的过程中,虽然仍有代码页字符警告,但是可以正常编译成功,不再象1.33.1那样造成正则表达式库不修改源码不能够编译通过的问题了。
下面的例子是从boost文档中来的:
#include <iostream>
#include <string>
#include <boost/python.hpp>
#include <boost/ref.hpp>
#include <vector>
using namespace boost::python;
void greet()
{
object main = import("__main__");
object global(main.attr("__dict__"));
// Define greet function in Python.
object result = exec(
"def greet(a): \n"
" return 'Hello %s from Python!' % a \n",
global, global);
object greet = global["greet"];
list lst;
lst.append(1);
lst.append(2);
object r = greet(lst);
std::string message = extract<std::string>(r);
std::cout << message << std::endl;
}
int _tmain(int argc, _TCHAR* argv[])
{
Py_Initialize();
greet();
system("Pause");
return 0;
}
相关文章推荐
- boost 1.34 终于简化了内嵌python的支持
- 终于在pycharm下(Python3.6.1版本)安装完成机器学习相关库文件(sklearn scikit-learn gensim xgboost tensorflow nltk )
- [导入]让Boost.python支持Boost::any类型。
- Scrapy 终于支持Python3啦
- 让Boost.python支持Boost::any类型。
- python 7-5 如何让类支持比较操作lt/le/total_ordering可以简化此过程,实现lt eq 后,可以推测出<= >=方法
- Android 上的 Chrome 终于,即将,就要,支持文件上传(input type="file")了?
- 多线程编程(1): python对多线程的支持
- boost.python入门教程 ----python 嵌入c++
- Python发送内嵌图片及附件
- Python对Xpath的支持
- 我用Python爬了7W知乎用户信息,终于捕获了心仪小姐姐......
- windows下安装xgboost for python 的简单方法
- python中的堆支持自定义的比较函数 - Heap in Python with comparator.
- Velt-0.2.6对Python远程调试的支持
- boostpython 环境搭建
- 方便的boost_python
- 使用Spring的JAVA Mail支持简化邮件发送
- Python Wing IDE6.0 安装和配置 支持2P和3P (新手推荐)
- xgboost python windows编译问题