PythonǶÈëC++Ïê½â(3)
¼Ìǰƪ¡¶Import Module¡·£¨http://blog.csdn.net/xiadasong007/archive/2009/09/02/4512797.aspx£©£¬¼ÌÐø·ÖÎöǶÈ벿·Ö»ù´¡ÖªÊ¶¡£Õâ´Î²»¶à˵£¬ÓÐʲôÎÊÌâ¼ÇµÃ¶à²éÓ¢ÎÄ×ÊÁÏ£¬¹úÄÚµÄÕâ·½Ãæ֪ʶÉÙ
»¹ÊÇÀ´¿´´úÂ룬дÍêÎÒ¾Í˯¾õÁË~
#include "python/python.h"
#include <iostream>
using namespace std;
int main(int argc,char** argv)
{
PyObject *pModule, *pClass,*pStuObj,*pFunc;
Py_Initialize();
////////////////
//ÔØÈëÄ£¿éstu.py
pModule = PyImport_ImportModule ("stu");
//´ÓÄ£¿éÖеõ½ÀàStudent
pClass = PyObject_GetAttrString (pModule, "Student");
//Éú³ÉÒ»¸öѧÉú¶ÔÏójack,×¢Òâ3.1°æ±¾±ØÐë¼ÓÉÏСÀ¨ºÅ£º(s)£¬·ñÔò»á³ö´í
//PyObject_CallObjectºÍÁíÍâÒ»¸ö³£ÓõÄPyEval_CallObjectÓ÷¨¼«ÎªÏà½ü£¬Çë¿´¸½Â¼²¿·ÖÏê½â
PyObject * temp=Py_BuildValue("(s)","jack");
pStuObj = PyObject_CallObject(pClass, temp);
//»ñµÃº¯Êý¶ÔÏójackÖеijÉÔ±º¯ÊýprintName£¬
//Õâ¸ögetattrµÄÒâ˼¾ÍÊǵõ½µ±Ç°¶ÔÏóµÄÊôÐÔ£¨²»Òª¾ÖÏÞÓÚC++ÖеÄÊôÐÔŶ£©
pFunc= PyObject_GetAttrString (pStuObj, "printName");
//µ÷Óú¯ÊýprintName
PyEval_CallObject (pFunc, NULL);
////////////////
Py_Finalize();
return 0;
}
/*
¸½Â¼£º
1£ºStudentÀ࣬ÎÒ·¢ÏÖprintºóÃæÏÖÔÚ±ØÐë¼ÓÉÏСÀ¨ºÅÁË£¬·ñÔò»áÓÐÎÊÌâ
class Student:
name=""
def __init__(self,name):
self.name=name
def printName(self):
print (self.name)
2£ºPyObject_CallObjectºÍ PyEval_CallObject²»Í¬Ö®´¦£º
¿ÉÒÔ¿´³ö£¬ºóÕß½ÏΪֱ½Ó£¬¶øÇÒ½ÓÊÜNULL£¬and does explicit type checks
for args and kwds.
PyObject_CallObject(PyObject *o, PyObject *a)
{
! PyObject *r;
! PyObject *args = a;
!
! if (args == NULL) {
! args = PyTuple_New(0);
! if (args == NULL)
! return NULL;
! }
!
! r = PyEval_CallObject(o, args);
!
Ïà¹ØÎĵµ£º
TIOBEÊÀ½ç±à³ÌÓïÑÔÅÅÐаñÕ¹ÏÖÁ˱à³ÌÓïÑÔµÄÁ÷ÐÐÇ÷ÊÆ¡£Ã¿¸öÔ£¬¶¼ÓÐ×îеÄÊý¾Ý±»¸üС£Õâ·ÝÅÅÐаñµÄÊý¾ÝÈ¡ÑùÀ´Ô´ÓÚ»¥ÁªÍøÉϸ»ÓоÑéµÄ³ÌÐòÔ±¡¢ÉÌ ÒµÓ¦Óá¢ÖøÃûµÄËÑË÷ÒýÇ棨ÖîÈç¹È¸è¡¢ MSN ¡¢ÑÅ»¢£©µÄ¹Ø¼ü×ÖÅÅÃû¡¢ Alexa ÉϵÄÅÅÃûµÈ¡£Çë×¢ÒâÕâ¸öÅÅÐаñÖ»ÊÇ·´Ó³ÁËij¸ö±à³ÌÓïÑÔµÄÈÈÃÅ³Ì¶È , Õâ²¢²»´ú±íËüÊÇÒ»¸ö×îºÃµÄ±à³ÌÓïÑÔ»òÊ ......
ż¶û×ö¸ö¼òµ¥µÄWEB·þÎñ²âÊÔ³ÌÐò£¬ÎÒ»¹ÊÇϲ»¶²ÉÓÃPHP¡£¼ò½à£¬·ç¸ñºÍC/C++½Ó½ü£¬ÉÏÊֿ죬¶øÇÒ¿âÒ²ºÜÆëÈ«¡£ÒÔǰΪ¹ã¶«Òƶ¯×öÒƶ¯ÐÐÒµÖն˵ÄÑÝʾ³ÌÐòʱ£¬²ÉÓùúÄÚÒ»¸öÐÖµÜдµÄFleaPHP¿ªÔ´¿ò¼Ü£¬Á½Öܲ»µ½µÄʱ¼ä£¬ÎÒ´ÓÒ»¸ö¶ÔPHPÒ»ÎÞËùÖªµÄˮƽ£¬¿ìËٵĸ㶨ÁË30¶à¸öÒ³ÃæµÄºǫ́£¬ºóÀ´ÑÝʾЧ¹ûÒ²²»´í£¬Ò²ºÜÎȶ¨£¬´Ó´Ë¶ÔPHPÓÐÁ ......
VB
If MSComm1.PortOpen = True Then MSComm1.PortOpen = False
MSComm1.CommPort = i1
MSComm1.PortOpen = True
MSComm1.InputMode = comInputModeBinary
MSComm1.InBufferCount = 0
& ......
1. ʼþÇý¶¯
Ò»¸öʼþ¼°Æä»Øµ÷µÄÀý×ÓÊÇÊó±êÒƶ¯¡£ÎÒÃǼÙÉèÊó±êÖ¸ÕëÍ£ÔÚÄúGUI ³ÌÐòµÄij´¦¡£Èç¹ûÊó±ê±»ÒƵ½Á˳ÌÐòµÄ±ð´¦£¬Ò»¶¨ÊÇÓÐʲô¶«Î÷ÒýÆðÁËÆÁÄ»ÉÏÖ¸ÕëµÄÒƶ¯£¬´Ó¶ø±íÏÖÕâÖÖλÖõÄתÒÆ¡£ÏµÍ³±ØÐë´¦ÀíÕâЩÊó±êÒƶ¯Ê¼þ²ÅÄÜÕ¹ÏÖ£¨²¢ÊµÏÖ£©Êó±êÔÚ´°¿ÚÉϵÄÒƶ¯¡£Ò»µ©ÄúÊÍ·ÅÁËÊó±ê£¬¾Í²»ÔÙ»áÓÐʼþÐèÒª´¦ ......