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ÊÇʲô£¿
Æäʵ£¬python¾ÍÊÇÒ»Ãűà³ÌÓïÑÔ£¬¾ÍÏñjavaÒ»Ñù¡£±¾À´ÊÇÔÚµçÄÔÉϵ쬵«ÊÇËæ×ÅÊÖ»úµÄÁ÷ÐУ¬python±»ÒÆÖ²µ½ÁËÊÖ»úÉÏ£¬Í¬Ê±Ò²±»ÃüÃûΪpyS60¡£
¶þ¡¢pyÈí¼þµÄ¹¹Ôì
ËùÓеÄpyÈí¼þ¶¼Òª°üÀ¨ÈçÏÂÎļþ£º.app--1.65k£».rsc--337b£».aif¡£ÕâÈý¸öÎļþÔÚËùÓÐpyÈí¼þÖж¼ÊÇÏàͬµÄ£¬Î¨Ò»µÄÇø±ð¾ÍÊÇÈí¼þµÄuid²»Í¬¡£ÕâЩÎļ ......
½ñÌì¿´¿´ÈçºÎÓÃpythonʵÏÖ×¥°ü¡£
ÒÔǰÎÒÃÇÔøÓùýwinpcapʵÏÖ×¥°ü£¬Æäʵ½ñÌìÎÒÃÇ»¹ÊÇÓÃËü£¬Ö»²»¹ýÊÇËüÔÚpythonϵÄÄ£¿é£¬ÔÚÓÃ֮ǰÎÒÃDZØÐëÏÈÏÂÔØÁ½¸ö¿â£¬pcap¿âºÍdpkt¿â£¬Õâ¸ö¿ÉÒÔÔÚGoogle codeÀïºÜÈÝÒ×ÕÒµ½£¬ÐèҪעÒâµÄÊÇpcapÖ»Ö§³Öµ½python2.5 £¬ËùÒÔÎÒÃÇÒªÓÃ2.5À´±àд¡£
°²×°ÍêÁ ......
PythonµÄ´´Ê¼ÈËΪGuido van
Rossum¡£1989ÄêÊ¥µ®½ÚÆÚ¼ä£¬ÔÚ°¢Ä·Ë¹Ìص¤£¬GuidoΪÁË´ò·¢Ê¥µ®½ÚµÄÎÞȤ£¬¾öÐÄ¿ª·¢Ò»¸öеĽű¾½âÊͳÌÐò£¬×öΪ ABC
ÓïÑÔµÄÒ»Öּ̳С£Ö®ËùÒÔÑ¡ÖÐ Python£¨´óòþÉßµÄÒâ˼£©×÷Ϊ³ÌÐòµÄÃû×Ö£¬ÊÇÒòΪËûÊÇÒ»¸öMonty PythonµÄ·ÉÐÐÂíÏ·Íŵİ®ºÃÕß¡£
ABCÊÇÓÉGuido²Î¼ÓÉè¼ÆµÄÒ»ÖÖ½ÌѧÓïÑÔ¡£¾ÍGuido±¾ÈË¿´ ......
¶ÔÊý¾Ý¿âµÄ²Ù×÷»ù±¾·ÖΪÈý²½£º
Á¬½ÓÊý¾Ý¿â
¸ù¾ÝÐèÒªÖ´ÐÐSQLÓï¾ä£¬½ÓÊÜ·µ»ØÖµ
¹Ø±ÕÁ¬½Ó
ÎÒÃÇÕý³£µÄÊý¾Ý¿âÓ¦¸Ã¶¼Àë²»¿ªÕâÈý²½£¬ÏÂÀ´ËµËµÈçºÎʹÓÃpythonÖеÄMySQLdbÄ£¿é½øÐÐÕâЩ²Ù×÷£º
Ê×ÏÈ£¬ÎÒÃÇÐèÒª°ÑMySQLdbÒýÈëµ½³ÌÐòÖÐ
import MySQLdb
È»ºó¿ªÊ¼Êý¾Ý¿â²Ù×÷
1.Êý¾Ý¿âÁ¬½Ó
conn = MySQLdb. ......
PythonµÄosÄ£¿é£¬°üº¬ÁËÆÕ±éµÄ²Ù×÷ϵͳ¹¦ÄÜ£¬ÕâÀïÖ÷ҪѧϰÓë·¾¶Ïà¹ØµÄº¯Êý£º
os.listdir(dirname)£ºÁгödirnameϵÄĿ¼ºÍÎļþ
os.getcwd()£º»ñµÃµ±Ç°¹¤×÷Ŀ¼
os.curdir:·µ»Øµ±Ç°Ä¿Â¼£¨'.')
os.chdir(dirname):¸Ä±ä¹¤×÷Ŀ¼µ½dirname
os.path.isdir(name):ÅжÏnameÊDz»ÊÇÒ»¸öĿ¼£¬name²»ÊÇĿ¼¾Í·µ»Øfalse
......