开发者

How to pass map into py?

开发者 https://www.devze.com 2023-01-04 18:56 出处:网络
I want to use c++ load py. But one of parameters of a function is dict. So, can I pass the map i开发者_运维知识库n C++ to dict in py?Your problem description is a little terse. If I understand corre

I want to use c++ load py.

But one of parameters of a function is dict.

So, can I pass the map i开发者_运维知识库n C++ to dict in py?


Your problem description is a little terse. If I understand correctly though, you'd like to embed a Python interpreter within a C++ application and, from C++, you want to be able to instruct the interpreter to load Python modules. If this is correct, then the answer is no. The Python C API expects a Python object whenever a dict is required. If you wish to use a C++ map, you'll have to use the Python C API and manually manage the coversion between the keys & values.

Depending on your needs, the Boost.Python library may be able to simplify some of the cross-language code for you.

0

精彩评论

暂无评论...
验证码 换一张
取 消