Ò׽ؽØͼÈí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö160KB

c++ÖÐǶÈëpythonÄ£¿éÖ¸ÕëΪ¿Õ,Ϊʲô

#include <Python.h>
#include <string>
#include <vector>
#include <iostream>
using namespace std;
int main(int argc, char* argv[])
{
vector <string> results;
PyObject *module,*liststr,*dic,*fun,*argss;
Py_ssize_t slen;
Py_Initialize();
if (!Py_IsInitialized())
{
cout < <"fail!" < <endl;
return 0;
}
        //ÏÂÃæÕâ¾ä¶¼ÄÜÕý³£Ö´ÐУ¬ËµÃ÷»·¾³ÉèÖÃÓ¦¸ÃûÎÊÌâ
PyRun_SimpleString("print('hello')");
        //ÕâÒÔºóµÄ¾Í²»ÐÐÁË£¬µ¼ÈëÄ£¿éÖ¸ÕëΪ¿Õ
module=PyImport_ImportModule("Helper");
if (!module)
{
return 0;
}
dic = PyModule_GetDict(module);
fun = PyDict_GetItemString(dic,"GetTokenizeResult");
argss = Py_BuildValue("(ss)","ds|fef|ggg|fes|fe","|");
liststr = PyObject_CallObject(fun,argss);
slen = PyList_Size(liststr);
for (int i=0;i <slen;i++)
{
string restr;
PyArg_Parse(PyList_GetItem(liststr,i),"s",&restr);
results.push_back(restr);
}
Py_Finalize();
return 0;
}

Çë´óÏÀÃÇ°ïæ¿´¿´Ôõô»ØÊ£¬ÎÊÌâÔÚ´úÂë×¢ÊÍÖУ¬»·¾³vs2005 python3.0¶øÇÒÏîÄ¿ÖеÄ×Ö·û¼¯×öÁ˸÷ÖÖÉèÖû¹ÊDz»ÐУ¬ÎÒ°ÑpythonµÄpy,ºÍÉú³ÉµÄpycÎļþÒ»Æ𿽵½c++¹¤³


Ïà¹ØÎÊ´ð£º

C ³ÌÐòÎÊÌâ (¶þ) - C/C++ / CÓïÑÔ

ÎÊһϣº
#include <stdio.h>
int main()
{
  char x, y, z;
  int i;
  int a[16];
  for(i=0; i<=16; i++)
  {
  a[i] = 0;
  ......

ÓÃc/c++¶¨Î»É¾³ýÒ»ÐеÄÎÊÌâ

ÓÃc/c++¶¨Î»É¾³ýÒ»ÐеÄÎÊÌâ¡£

ÎÊÌâ±³¾°£º

ËùÐèÊý¾ÝÏ൱´ó¡£aÓëbÎļþ¾ùΪһ×éÎļþ£¨a1£¬a2¡­£¬b1£¬b2¡­£©£¬aÎļþÓÐ×î´óÊý¾ÝÐÐÊý£¨Èç5000£©£¬ÒÔÐеÄÐÎʽ£¬´ÓaÎļþÖжÁÈ¡Êý¾Ý£¬½«aÖв»ÄÜ´¦ÀíµÄÊý¾Ý·ÅÔÚbÎ ......

cºÍc++ÖеÄconstµÄÇø±ð

ÏÈ¿´Ò»¸ö³ÌÐò
#include <stdio.h>

int main()
{
const int a = 5;
int b[a];

return 0;
}
ÔÚvc6.0ÖÐÃüÃûΪ.cÎļþ£¬±àÒë»á³ö´í£¬ÊÇint b[a]ÕâÒ»ÐУºexpected constant exp ......

linux»·¾³ÏÂgethostbynameº¯ÊýÎÊÌâ - C/C++ / CÓïÑÔ

дÁ˸ö²âÊÔ³ÌÐòÈçÏÂ
   
  struct hostent *hp; 
char AlarmDevIP[20];  
  int x2;

hp = gethostbyname("www.google.com");
if (hp)
{ ......

eric4ÔõôÔËÐÐpython³ÌÐò£¿

pythonºÍpyqtÒÔ¼°Eric4¶¼ÒѾ­ÅäÖúÃÁË£¬´ò¿ªEric4д¸öpython³ÌÐò±ÈÈç¼òµ¥µÄ
print¡°hello£¬world¡±£¬Ôõô±àÒëÔËÐÐÁË£¬Start²Ëµ¥µÄËùÓÐÃüÁ³öÏÖºÍͼÖв¶àµÄ¶Ô»°¿ò£¬Ó¦µ±ÔõôÔËÐÐÁË£¿

Çó´ó¼ÒÖ¸½Ì

ûÓÐÈËÓà ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ