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·â×°£¿
ͬÒ⣬BoostÒ²²»ÊÇÍòÄܵģ¬»¹ÊÇÓкܶàËü²»ÄÜ°ü×°µÄ¶«Î÷¡£
xxx(&_x)´«µÝµÄÊÇ_xµÄµØÖ·£¬Òª´«µÄÊÇÒ»¸öÒýÓã¬ÔÚC++Àï±àÒ뱨´í£¬ÎÞ·¨½«int* ת»¯Îªint&£¬¸ÃÔõôÉè¼Æ£¿
°¡...Ã÷ÏÔ²ÎÊý´íÁË£¬Ò²Â©·µ»ØÖµ¡£ÊÔÊÔ¸üÕýº¯ÊýÌåΪ{xxx(_x);return _x;}
Ïà¹ØÎÊ´ð£º
×î½üÓÃpythonдһ¸ö³ÌÐò,×ÜÊÇÒì³£Í˳ö£¬µ«ÊÇȴû·¨ÓÃtry..exceptÀ´²¶×½
ÓÉÓÚû·¨·¢Í¼Æ¬£¬ËùÒÔ°ÑÏà¹ØµÄÐÅÏ¢´òÓ¡³öÀ´
Òì³£µÄÐÅÏ¢´óÖÂÈçÏ£º
python.exeÓöµ½ÎÊÌâÐèÒª¹Ø±Õ¡£ÎÒÃǶԴËÒýÆðµÄ²»±ã±íʾ±§Ç¸ ......
ʹÓÃÔ´Îļþ
#!/usr/bin/python
# Filename : helloworld.py
print 'Hello World'
ÎÒÔõôҲ¿´²»¶®£¡Ö»ÊÇ×îºóÒ»ÐÐÎÒÖªµÀ~~Ç°ÃæÁ½ÐÐÊÇʲôÒâ˼ÄØ£¿
½Ì³ÌÉÏ˵Èç¹ûÄãʹÓÃIDLE£¬ÇëʹÓò˵ ......
Ïñ C µÄ scanf() ÄÇÑù
±ÈÈç¶ÁÈë 1 2 3 a b c
ÿ´Î¶ÁÈëÒ»¸ö
ÏÂÃæÕâ¸öÓ¦¸ÃÊÇÄãÏëÒªµÄ°É£º
Python code:
>>> k = raw_input()
0 0123 ds dsl sd
>>> k
'0 0123 ds dsl sd'
>>> ......
s='aaa111aaa,bbb222,333ccc,444ddd444,555eee666,fff777ggg'
ÓÃÕýÔò±í´ïʽȡ³ö Ç°ºó×ÖĸÏàͬµÄÊý¾Ý ½á¹ûÈçÏÂ:
111 ddd
лл~
Python code:
import re
s='aaa111aaa,bbb222,333ccc,444ddd444,555eee666,ff ......
´úÂë:
timeout = 10
socket.setdefaulttimeout(timeout)
sock = urllib2.urlopen(url)
html = sock.read()
Ò»°ãÇé¿öÄÜÐУ¬ÔËÐÐûÎÊÌ⣠......