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

pythonÈëÃż¶ÎÊÌâ

ÇëÎÊÈçºÎ½«ËùÓÐprintµÄÐÅÏ¢Ò»´Îд³ÉÒ»¸ötxtÎı¾£¬Ð»Ð»£¡
¿ÉÒÔʹÓÃÄÚÖú¯Êý
configfile = open('test.txt','a')  ##open·½·¨µÄÁ½¸ö²ÎÊý£¬µÚÒ»¸öÊÇҪдµÄtxtÎı¾µÄ·¾¶ºÍÃû×Ö
configfile.writelines(str)  ##strÊÇÄãÒªprintµÄÐÅÏ¢£¬¼´ÎªÒªÐ´ÈëtxtµÄÎı¾
configfile.close()

¿ÉÄÜÎÒ˵µÄ»¹²»ÊǺÜÇå³þ£¬ÎÒÊÇÏë°ÑÆÁÄ»´òÓ¡µÄÄÚÈÝдµ½ÎļþÀïÃæ¡£

print >>open(filename,'r or w ÍüÁË')  ¼òµ¥°É

ÎÒÊÔÁËһϣ¬»¹ÊDz»Äܽ«´òÓ¡µÄÄÚÈݱ£´æÔÚÎļþÀïÃæ°¡¡£
print 'test for file'
print >> open(filename, 'wt')
ÕâÑù³öÀ´Ö»ÊÇÒ»¸ö¿ÕµÄÎļþ£¬ÀïÃæûÓÐtest for fileÕâ¾ä»°...

file = open(r"file_name", 'w')
print >> file, "hello, world"

¿ÉÒÔ²»¸ÄÔ­À´½Å±¾£¬ÔÚ¿ØÖÆ̨ÏÂÖ´ÐÐʱÖض¨Ïòµ½Ò»¸öÎļþ£¬Æ©Èç
python.exe xxx.py > xxx.txt


¸Ðл¥ÉÏ£¡£¡£¡

ÓÃpython 3.0ÒÔÉÏ°æ±¾, printº¯ÊýµÄfilename²ÎÊýÖ±½ÓÖ§³Öдµ½Îı¾

¸Õ²ÅŪÁ˸öeclipse + pydevµÄIDE£¬·¢ÏÖ²»ÄÜdebug
´íÎóÌáʾ
Traceback (most recent call last):
  File "F:\tools\eclipse\plugins\org.python.pydev.debug_1.5.3.1260479439\pysrc\pydevd.py", line 2, in ?
    from pydevd_constants import * #@UnusedWildImport
  File "F:\tools\eclipse\plugins\org.python.pydev.debug_1.5.3.1260479439\pysrc\pydevd_constants.py", line 63, in ?
    DictContains = dict.has_key
NameError: name 'di


Ïà¹ØÎÊ´ð£º

python Òì³£Í˳ö

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

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

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

³ÏÕÐPython³ÌÐòÔ±²ÎÓë¼ÆËã»úÊé¼®³ö°æ

ÓźñµÄ¸å³ê£¬³ÏÕÐPython¼¼ÊõÈËÔ±²ÎÓë¸÷ÖÖ¼¼ÊõÊé¼®³ö°æ¡£ 
ͨ¹ý¸ÃÊé¼®£¬×÷Õß¿ÉÒԵõ½Èçϱ¨³ê£º 
1¡¢·áºñµÄ¸å³ê¡£ 
2¡¢Êé¼®Öø×÷µÄÊðÃûȨ¡£ 
3¡¢¶Ô×÷ÕߺÍÊé½øÐÐÐû´«£¬Ìá¸ß×÷ÕßÔÚ¼¼ÊõȦ×ÓÀ ......

boost.python c++ǶÈëpythonÈçºÎÖØÔØ=£¿

ÎÒÏÖÔÚÓÐÒ»¸öÐèÇóÊÇÕâÑùµÄ
ÎÒÓÐ2¸öÀà
class A
{
public:
int val;
}

class B
{
public:
A a
}

ÏÖÔÚÔڽű¾ÖÐÖ»ÄÜ
b.a.val = 1
ÎÒÔÚpythonÖÐÏëʹÓÃ
b.a = 1
......

ÎÒÔÚÓÃPYTHONдץ°ü³ÌÐò,Ò»Ö±Ìáʾģ¿éûÓб»µ÷ÓÃ

Ô´³ÌÈçÏÂ:

Python code:

import pcap
import dpkt
pc = pcap.pcap();


µÚÒ»ÐÐ,µÚ¶þÐж¼Ã»ÓÐÎÊÌâ,¾ÍÊǵÚÈýÐб¨´í,°¦,ÕÛÌںþÃÁË,ÕæÏë·ÅÆúPYTHON

E:\cmd>pcap.py
Traceback (most r ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ