Python 3 Êä³öÖض¨ÏòʹÓÃC/C++
Python 3 Êä³öÖض¨ÏòʹÓÃC/C++
By:gddsky
Ä¿±ê
Ï£Íû½«Python 3µÄÊä³öÖض¨Ïòµ½×Ô¶¨ÒåµÄÊä³öÄ¿±ê¡£
ºËÐÄ
PythonʹÓÃsys.stdout¡¢sys.stderr×öÊä³öÄ¿±ê£¬Ö»ÒªÎÒÃÇÌæ»»ÕâÁ½¸öÖµ¾Í¿ÉÒÔÖض¨Ïòµ½ÎÒÃÇ×Ô¶¨ÒåÄ¿±ê¡£Ìæ»»µÄÖµµÄ¹æÔòÔÚPythonµÄÎĵµÖÐsys (module)µÄsys.stdoutÉÏÃæ˵Ã÷Ö»ÒªÌí¼ÓÒ»¸öwriteº¯Êý¾Í¿ÉÒÔÁË¡£ÏñÕâÑù£º
write(self, str)
ÎÒÃÇÖ»ÒªÔÚÕâ¸öº¯ÊýÀïÃæµ÷ÓÃÎÒÃÇ×Ô¼ºµÄÊä³öº¯Êý¾Í¿ÉÒÔʵÏÖ¸ÃÄ¿±êÁË¡£
·½°¸
ÔÚC++ÖÐдһ¸öPythonÄ£¿é£¬²¢µ¼Èë
ÔÚC++ÖÐÀûÓÃPyRun_SimpleString½¨Á¢Ò»¸öPyObjectÈ¥Ìæ»»ÔʼµÄsys.stdout¡¢sys.stderr
¸ã¶¨£¡£¡£¡
´úÂë
Ä£¿é¶¨Ò岿·Ö´úÂ루ÓÃpython demoϵÄÀý×Ó¸ÄдµÄ£©
static PyObject *console_write(PyObject *self, PyObject* args)
{
if (s_pyConsoleNotify != NULL)
{
const char* pMsgString=0;
if (!PyArg_ParseTuple( args, "s", &pMsgString ))
{
return NULL;
}
// ÎÒÃÇ×Ô¼ºµÄÊä³öº¯Êý
myprint(pMsgString);
}
Py_INCREF( Py_None );
return Py_None;
}
static PyMethodDef console_methods[] = {
{"test", console_test, METH_NOARGS, "Return the meaning of everything."},
{"write", console_write, METH_VARARGS, NULL},
{NULL, NULL} /* sentinel */
};
static struct PyModuleDef consolemodule = {
{}, /* m_base */
"console_capi", /* m_name */
0, /* m_doc */
0, /* m_size */
console_methods,
Ïà¹ØÎĵµ£º
Python×÷ΪһÖÖ¹¦ÄÜÇ¿´óÇÒͨÓõıà³ÌÓïÑÔ¶ø¹ãÊܺÃÆÀ£¬Ëü¾ßÓзdz£ÇåÎúµÄÓï·¨Ìص㣬ÊÊÓÃÓÚ¶àÖÖ²Ù×÷ϵͳ£¬Ä¿Ç°ÔÚ¹ú¼ÊÉϷdz£Á÷ÐУ¬ÕýÔڵõ½Ô½À´Ô½¶àµÄÓ¦Óá£
ÏÂÃæ¾ÍÈÃÎÒÃÇÒ»ÆðÀ´¿´¿´ËüµÄÇ¿´ó¹¦ÄÜ£º
Python£¨ÅÉÉ£©£¬ËüÊÇÒ»¸ö¼òµ¥µÄ¡¢½âÊÍÐ͵ġ¢½»»¥Ê½µÄ¡¢¿ÉÒÆÖ²µÄ¡¢ÃæÏò¶ÔÏóµÄ³¬¸ß¼¶ÓïÑÔ¡£Õâ¾ÍÊǶÔPython ......
¿É¶ñ¡¢¿É±¯¡¢¿É³Ü¡¢¿ÉÁ¯¡¢¿É̾¡¢¿ÉЦ£¡£¡£¡
2009Äê10ÔÂ15ÈÕ£¬Ò»¸öÁî¹ã´ópython±à³Ì¹¤×÷°®ºÃÕß¿ÞЦ²»µÃµÄÊ·¢ÉúÁË——pythonµÄ¹Ù·½ÍøÕ¾£¨http://www.python.org£©±»Î°´óµÄÌ쳯¸ø·âÁË£¡
µ±Ê±£¬ÓÐÈË˵ÊÇÒòΪÓÐÒ»¸öHÍøÕ¾ºÍpythonµÄ¹ÙÍøºÜÏñ£¬·â´íÁË¡£ÓÚÊÇ£¬ÎÒÊÔ×Å´ò¿ªÁËÄǸö“ÏàËƵÄÍøÕ¾http://www.python.com ......
±àÒëPython½Å±¾Éú³É¿ÉÖ´ÐгÌÐò£¬¿ÉÒÔͨ¹ýpy2exe±àÒëÍê³É¡£
ÔÚVCÖе÷ÓÃpythonʱ£¬¿ÉÒÔ½áºÏpy2exe£¬Íê³ÉÕû¸ö³ÌÐòµÄ¶ÀÁ¢·¢²¼^_^
google.py:
#! /usr/bin/env python
import sys, webbrowser
def main(a):
url = "http://www.google.com/search?q=%s" % a
webbrowser.o ......
Õâ¸öÊÇ1.10°æ±¾µÄ²ÂÊý×Ö£¬ËäÈ»´úÂë»ù±¾²»±ä£¬µ«ÊDZäµÄÊÇ˼ά·½Ê½£¬²»ÔÙÊÇÓÃÃæÏò¹ý³ÌµÄ·½·¨£¬¶ø¸ÃΪÓÃÀàÀ´ÊµÏÖ£¬±È½ÏÇ°ºóµÄ´úÂ룬ÕâÒ»¸ö¼ò½à¶àÁË£¬¶øÇÒ¸üÈÝÒ×Àí½â£¡
¸üУº
#1.0°æ±¾ÖеÄÌáʾÀàÐÍÊÇ£ºAABB£¬¼òµ¥µÄ˵¾ÍÊÇÏà¶ÔλÖõÄÊý×Ö¶ÔÁ˾ÍÏÔʾA£¬´íÁ˾ÍÏÔʾB£»
#ÏÖÔÚµÄÌáʾ¸ÄΪ£º0A4B¸ñʽ£¬Ò²¾ÍÊÇ˵²»ÌáʾÄǸöλÖõÄÊý× ......
http://sourceforge.net/projects/pyexcelerator/
12ÔÂ2ÈÕ
python ¶ÁдExcelÎļþ£¨×ªÌû limodou£©
http://www.lexicon.net/sjmachin/xlrd.htm
Õâ¸ö°üÊÇÓÃÀ´¶ÁExcelÎļþµÄ
ÔÚ·¢ÏÖ xlrd Ö®ºó²»¾Ã¾Í·¢ÏÖÁË pyExcelerator
£¬ËüÓë xlrd ²»Í¬£¬ËüÖ÷ÒªÊÇÓÃÀ´Ð´ Excel Îļþ£¬µ±È»¶ÁÒ²ÊÇûÓÐÎÊÌâµÄ¡£ÏÂÃæ¾ÍËüµÄʹÓüòµ¥µØ½éÉ ......