C++ python 交互之 python.dict to c++ map
2011-05-06 20:49
666 查看
代码片段如下,
typedef map<string ,string> smap;//要转换的目的map
转换函数
string req_update_userprofile_pack_data2(std::string workkey,PyObject *dict_user)
{
Py_ssize_t i, j;
i = 0;
PyObject *key;
PyObject *value;
smap m_profilelist;
while (PyDict_Next(dict_user, &i, &key, &value)) //C++中遍历python的dict对象。此为关键代码
{
char * skey = PyString_AS_STRING(key);
char * svalue = PyString_AS_STRING(value);
string sskey(skey);
string ssvalue(svalue);
if (sskey != "")
{
cout<< ssvalue << endl;
m_profilelist[sskey] = ssvalue;
}
cout << skey << endl;
}
cout <<"get bloadtype"<<m_profilelist["bloodType"] << endl;
.....还有其他项目中的代码
return buf;
}
typedef map<string ,string> smap;//要转换的目的map
转换函数
string req_update_userprofile_pack_data2(std::string workkey,PyObject *dict_user)
{
Py_ssize_t i, j;
i = 0;
PyObject *key;
PyObject *value;
smap m_profilelist;
while (PyDict_Next(dict_user, &i, &key, &value)) //C++中遍历python的dict对象。此为关键代码
{
char * skey = PyString_AS_STRING(key);
char * svalue = PyString_AS_STRING(value);
string sskey(skey);
string ssvalue(svalue);
if (sskey != "")
{
cout<< ssvalue << endl;
m_profilelist[sskey] = ssvalue;
}
cout << skey << endl;
}
cout <<"get bloadtype"<<m_profilelist["bloodType"] << endl;
.....还有其他项目中的代码
return buf;
}
相关文章推荐
- C++ python 交互之 python.dict to c++ map
- c++ python交互之boost.python 简集之Map处理
- c++ python交互之boost.python 简集之Map处理
- c++ python交互之boost.python 简集之Vector(map)混合使用
- c++ python交互之boost.python 简集之Vector(map)混合使用
- Linux下利用ZeroMQ让C++和Python交互
- Python 与 C++ 的交互编程
- Python 与 C++ 的交互编程
- use boost.python to Warp C++ for python
- python c++ 交互之管道 pipe
- Python 与 C++ 的交互编程
- Python error: Microsoft Visual C++ 9.0 is required (Unable to find vcvarsall.bat)解决方案
- 转:python 3.4 error: Microsoft Visual C++ 10.0 is required(Unable to find vcvarsall.bat)解决办法,自研亲测可行
- Python: Windows下pip安装库出错:Microsoft Visual C++ 9.0 is required < Unable to find vcvarsall.bat
- Python 与 C++ 的交互编程
- Python与C++数据交互编码问题
- C++与python交互
- how to call c++ function in python coding in linux?
- 趣学python34字典dict,映射map
- Python与C++进行交互