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

boost python´«µÝÒýÓã¿

void xxx(int& x)
{
    x = 100;
}
def("xxx", xxx);

import y
a = 0
y.xxx(a)
±¨´íÁË£º
ArgumentError: Python argument types in
    L0_L1.xxx(int)
did not match C++ signature:
    xxx(int {lvalue})


ÇëÎÊÏñÕâÖÖ´«µÝÒýÓõĺ¯ÊýÈçºÎÓÃboost·â×°£¿


ÒýÓÃ
´«ÒýÓÃÊʺÏ×Ô¼ºÉè¼ÆµÄÀà»ò½á¹¹£¬»ù´¡ÀàÐÍÒªÉÔ΢°üװһϣ¬Æ©Èç¼òµ¥¶¨ÒåÁíÍâÒ»¸öº¯ÊýÀ´ºô½ÐÔ­º¯Êý£º
int _xxx(int _x){xxx(&_x)};È»ºódef("xxx",_xxx)...
ͬÒ⣬BoostÒ²²»ÊÇÍòÄܵģ¬»¹ÊÇÓкܶàËü²»ÄÜ°ü×°µÄ¶«Î÷¡£

ÒýÓÃ
´«ÒýÓÃÊʺÏ×Ô¼ºÉè¼ÆµÄÀà»ò½á¹¹£¬»ù´¡ÀàÐÍÒªÉÔ΢°üװһϣ¬Æ©Èç¼òµ¥¶¨ÒåÁíÍâÒ»¸öº¯ÊýÀ´ºô½ÐÔ­º¯Êý£º
int _xxx(int _x){xxx(&_x)};È»ºódef("xxx",_xxx)...

xxx(&_x)´«µÝµÄÊÇ_xµÄµØÖ·£¬Òª´«µÄÊÇÒ»¸öÒýÓã¬ÔÚC++Àï±àÒ뱨´í£¬ÎÞ·¨½«int* ת»¯Îªint&£¬¸ÃÔõôÉè¼Æ£¿

°¡...Ã÷ÏÔ²ÎÊý´íÁË£¬Ò²Â©·µ»ØÖµ¡£ÊÔÊÔ¸üÕýº¯ÊýÌåΪ{xxx(_x);return _x;}

ÒýÓÃ
ÒýÓà 1 Â¥ angel_su µÄ»Ø¸´:
´«ÒýÓÃÊʺÏ×Ô¼ºÉè¼ÆµÄÀà»ò½á¹¹£¬»ù´¡ÀàÐÍÒªÉÔ΢°üװһϣ¬Æ©Èç¼òµ¥¶¨ÒåÁíÍâÒ»¸öº¯ÊýÀ´ºô½ÐÔ­º¯Êý£º
int _xxx(int _x){xxx(&_x)};È»ºódef("xxx",_xxx)...

xxx(&_x)´«µÝµÄÊÇ_xµÄµØÖ·£¬Òª´«µÄÊÇÒ»¸öÒýÓã¬ÔÚC++Àï±àÒ뱨´í£¬ÎÞ·¨½«int* ת»¯Îªint&£¬¸ÃÔõôÉè¼Æ£¿



Ïà¹ØÎÊ´ð£º

python Òì³£Í˳ö

×î½üÓÃpythonдһ¸ö³ÌÐò,×ÜÊÇÒì³£Í˳ö£¬µ«ÊÇȴû·¨ÓÃtry..exceptÀ´²¶×½

ÓÉÓÚû·¨·¢Í¼Æ¬£¬ËùÒÔ°ÑÏà¹ØµÄÐÅÏ¢´òÓ¡³öÀ´
Òì³£µÄÐÅÏ¢´óÖÂÈçÏ£º

python.exeÓöµ½ÎÊÌâÐèÒª¹Ø±Õ¡£ÎÒÃǶԴËÒýÆðµÄ²»±ã±íʾ±§Ç¸ ......

python½Ì³ÌÖÐʹÓÃÔ´ÎļþµÄÎÊÌâ~~

ʹÓÃÔ´Îļþ

#!/usr/bin/python
# Filename : helloworld.py
print 'Hello World'

ÎÒÔõôҲ¿´²»¶®£¡Ö»ÊÇ×îºóÒ»ÐÐÎÒÖªµÀ~~Ç°ÃæÁ½ÐÐÊÇʲôÒâ˼ÄØ£¿
½Ì³ÌÉÏ˵Èç¹ûÄãʹÓÃIDLE£¬ÇëʹÓò˵ ......

[ÌáÎÊ]Python ÈçºÎºöÂÔ whitespace ¶ÁÈë

Ïñ C µÄ scanf() ÄÇÑù
±ÈÈç¶ÁÈë 1 2 3 a b c
ÿ´Î¶ÁÈëÒ»¸ö
ÏÂÃæÕâ¸öÓ¦¸ÃÊÇÄãÏëÒªµÄ°É£º
Python code:

>>> k = raw_input()
0 0123 ds dsl sd
>>> k
'0 0123 ds dsl sd'
>>> ......

pythonÕýÔò±í´ïʽ ÈçºÎÈ¡³öÒÔÏÂ×Ö·û´® ¶àл

s='aaa111aaa,bbb222,333ccc,444ddd444,555eee666,fff777ggg'
ÓÃÕýÔò±í´ïʽȡ³ö Ç°ºó×ÖĸÏàͬµÄÊý¾Ý ½á¹ûÈçÏÂ:
111 ddd
лл~
Python code:

import re
s='aaa111aaa,bbb222,333ccc,444ddd444,555eee666,ff ......

python ÅÀÈ¡ÍøÒ³ÊdzöÏֵĴíÎó

´úÂë:
    timeout = 10
    socket.setdefaulttimeout(timeout)
    sock = urllib2.urlopen(url)
    html = sock.read()
Ò»°ãÇé¿öÄÜÐУ¬ÔËÐÐûÎÊÌ⣠......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ