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

Python ÖÐÁгöĿ¼ÖÐËùÓÐÎļþµÄ·½·¨


Python´úÂë
import string, os, sys   
  
dir = '/var'  
print '----------- no sub dir'  
  
files = os.listdir(dir)   
for f in files:   
    print dir + os.sep + f   
  
print '----------- all dir'  
  
for root, dirs, files in os.walk(dir):   
    for name in files:   
        print os.path.join(root, name)  
import string, os, sys
dir = '/var'
print '----------- no sub dir'
files = os.listdir(dir)
for f in files:
print dir + os.sep + f
print '----------- all dir'
for root, dirs, files in os.walk(dir):
for name in files:
print os.path.join(root, name)
 
Ç°ÃæµÄ os.listdir ¿ÉÒÔÁгö dir ÀïÃæµÄËùÓÐÎļþºÍĿ¼£¬µ«²»°üÀ¨×ÓĿ¼ÖеÄÄÚÈÝ¡£os.walk ¿ÉÒÔ±éÀúÏÂÃæµÄËùÓÐĿ¼£¬°üÀ¨×ÓĿ¼¡£


Ïà¹ØÎĵµ£º

Óà python ¿ìËÙ´î½¨ÍøÓηþÎñÆ÷

ÀµÓºƣ¨http://laiyonghao.com£©
½ñÌ죨2009Äê5ÔÂ31ÈÕ£© OurPNP.org ¸ãÁ˸ö¾Û»á»î¶¯£¬ÅªÁËÊ®¼¸¶þÊ®¸öÈËÔÚ¹ãÖݺ£Öé¹ã³¡µÄÌûá´ôÁËÎå¸öСʱ£¬´´ÏÂÁËÎÒÔÚ K ·¿´ôµÄ×ʱ¼ä¼Í¼¡£Ó¦ËûÃǵÄÑûÇ룬ÎÒ×öÁ˸öÌâΪ¡¶Óà python ¿ìËÙ´î½¨ÍøÓηþÎñÆ÷¡·µÄСÑݽ²£¬ÒòΪÄDZߵĵçÊÓ¾¹È»²»ÄܽӵçÄÔ£¬ËùÒÔ½²µÄʱºòûÓÐÄܹ»²ÎÕÕ PPT À´½²£¬¹Û ......

pythonѧϰ±Ê¼Ç——pcap×¥°ü

½ñÌì¿´¿´ÈçºÎÓÃpythonʵÏÖ×¥°ü¡£
    ÒÔǰÎÒÃÇÔøÓùýwinpcapʵÏÖ×¥°ü£¬Æäʵ½ñÌìÎÒÃÇ»¹ÊÇÓÃËü£¬Ö»²»¹ýÊÇËüÔÚpythonϵÄÄ£¿é£¬ÔÚÓÃ֮ǰÎÒÃDZØÐëÏÈÏÂÔØÁ½¸ö¿â£¬pcap¿âºÍdpkt¿â£¬Õâ¸ö¿ÉÒÔÔÚGoogle codeÀïºÜÈÝÒ×ÕÒµ½£¬ÐèҪעÒâµÄÊÇpcapÖ»Ö§³Öµ½python2.5 £¬ËùÒÔÎÒÃÇÒªÓÃ2.5À´±àд¡£
    °²×°ÍêÁ ......

pylibpcap: python module for libpcap

#!/usr/bin/env python2
import pcap
import sys
import string
import time
import socket
import struct
protocols={socket.IPPROTO_TCP:'tcp',
           socket.IPPROTO_UDP:'udp',
           socket ......

Python¶àÏß³Ì ¼òÃ÷Àý×Ó

×ÛÊö
 
  ¶àÏß³ÌÊdzÌÐòÉè¼ÆÖеÄÒ»¸öÖØÒª·½Ã棬ÓÈÆäÊÇÔÚ·þÎñÆ÷Deamon³ÌÐò·½Ãæ¡£ÎÞÂÛºÎÖÖϵͳ£¬Ï̵߳÷¶ÈµÄ¿ªÏú¶¼±È´«Í³µÄ½ø³ÌÒª¿ìµÃ¶à¡£
 
Python¿ÉÒÔ·½±ãµØÖ§³Ö¶àÏ̡߳£¿ÉÒÔ¿ìËÙ´´½¨Ï̡߳¢»¥³âËø¡¢ÐźÅÁ¿µÈµÈÔªËØ£¬Ö§³ÖÏ̶߳Áдͬ²½»¥³â¡£ÃÀÖв»×ãµÄÊÇ£¬PythonµÄÔËÐÐÔÚPython
ÐéÄâ»úÉÏ£¬´´½¨µÄ¶àÏß³Ì¿É ......

pythonѧϰ±Ê¼Ç

typeÏà¹Ø£º
ËùÓÐ×Ô¶¨ÒåÀàA
ÆäʵÀý£¬Èç a = A()
ʹÓÃtypeÔËËã·û·µ»ØµÄ¶¼ÊÇ<type, 'instance'>
¶ø»ù±¾ÀàÐÍ
±ÈÈç b = 3
type(b)£¬½á¹ûÊÇ<type, 'int'>
pythonµÄtype²»ÏñC++ÖеÄtypeidÄÇÑù£¬¿ÉÒÔÏÔʾÀàÃû¡£
£¨×¢£º¶ÔÓÚûÓÐvirtualº¯ÊýµÄÀà¶øÑÔ£¬typeidÊDZàÒëʱÆÚµÄÊÂÇ飨Ҳ¾ÍÊǾ²Ì¬ÀàÐÍ£©£»¶ÔÓÚÓÐvirtualº¯ ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØÍ¼ | ¸ÓICP±¸09004571ºÅ