吸毒的虫子 发表于 2018-8-8 13:30:03

C++ python 交互之 python.dict to c++ 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 = ssvalue;
  }
  cout << skey << endl;
  }
  cout <<"get bloadtype"<<m_profilelist["bloodType"] << endl;
页: [1]
查看完整版本: C++ python 交互之 python.dict to c++ map