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

PythonʵÏÖ¡°¸÷ÀàÐÍÎļþͳ¼Æ¡±¹¦ÄÜ

²»¶à˵ÁË£¬Ö±½Ó¿´´úÂë°É£¡
import os
path = 'e:/Download/'
kzm = []
kzmTemp = set()
kzmTemp2 = []
dict = {}
for root,dirs,files in os.walk(path):
    for file in files:
        ext = os.path.splitext(file)[1][1:]
        kzm.append(ext)
#±éÀúĿ¼path£¬ÕâÀïÓõ½µÄsplitext()·½·¨Êǽ«ÎļþÃûºÍÀ©Õ¹Ãû·Ö¿ª£¬ºóÃæµÄ[1]´ú±íÈ¡À©Õ¹Ãû£¨[0]µÄ»°¾Í´ú±íÈ¡ÎļþÃûÁË£©£¬ÓÉÓÚsplitext()·½·¨È¡À©Õ¹ÃûµÄʱºò£¬ÊÇÁ¬·Ö¸ôÎļþÃûºÍÀ©Õ¹ÃûµÄ‘.’Ò»ÆðÈ¡µÄ£¬ËùÒÔ[1:]µÄ×÷ÓõÄÊÇÈ¥µôÀ©Õ¹ÃûÇ°Ãæµã
for i in range(len(kzm)):
    kzm[i] = kzm[i].lower()
#È«²¿±äСд£¬±ÜÃâÀýÈçexeºÍEXEϵͳ»áµ±×öÁ½ÖÖÎļþÀ´´¦ÀíµÄÎÊÌâ
for i in range(len(kzm)):
    kzmTemp.add(kzm[i])
#½«Listת»»ÎªSet£¬Ä¿µÄÊÇΪÁ˽«SetÖеÄËùÓÐÔªËØ×÷ΪDictÖеÄKey£¬ÒòΪSet»á×Ô¶¯ÌÞ³ýÖظ´µÄÔªËØ
kzmTemp2 = [i for i in kzmTemp]
for i in range(len(kzmTemp2)):
    dict[kzmTemp2[i]] = 0
#ÕâÀï¹¹ÔìÁËÒ»¸ö½Ð×ödictµÄDict£¨ºÃÈÆ×죩£¬²¢½«ËùÓеÄÀ©Õ¹Ãû¶¼×÷ΪdictµÄkey£¬¸øËùÓеÄkey¶¼¸³ÖµÎª0
for i in range(len(kzm)):
    dict[kzm[i]] += 1
#±éÀúÊý×ékzm£¬Í³¼Æ¸÷À©Õ¹Ãû³öÏֵĴÎÊý£¬È»ºó½«Õâ¸öÊý×Ö¸³Öµ¸ødictÖÐÏàÓ¦µÄkey
print('ͳ¼ÆµÄĿ¼Ϊ£º%s' % path)
for key in dict:
    print('%s£º %s' % (key,dict[key]))
´úÂëÒ»µãÒ²²»ÓÅÃÀ£¬À´»Øת»»ÁËN´ÎÊý¾ÝÀàÐÍ£¬forÁËN´Î……‘
²»¹ý¿ÉÒÔ½â¾öÎÊÌ⡣֪ʶÓÐÏÞ£¬Ö»ÄÜÓÃһЩ“ÈëÃż¶”µÄ·½·¨È¥½â¾öÎÊÌâ¡£


Ïà¹ØÎĵµ£º

python·ÃÎÊ sql server

½ñÌìÊÔÑéʹÓÃpythonÁ¬½Ó sql server ·þÎñÆ÷¡£ÎҼǵÃÒÔǰʹÓÃadoÁ¬½Óaccess·Ç³£Ë³Àû£¬µ«ÊǽñÌìʹÓÃadoÁ¬½Ósql server¾¹È»²»³É¹¦¡£ÔÚpythonÀïÃæµÄ³ö´íÐÅÏ¢¶¼ÏÔʾΪתÒÆÐòÁУ¬·ÑÁË°ëÌì¾¢²Å¸ãÃ÷°×£ºÎÞЧµÄÀà±ð×Ö·û´®¡£
ÊÇÁ¬½Ó×Ö·û´®Â𣿲âÊÔÁ˺ü¸¸ö È·ÈÏÎÞÎóµÄÊý¾Ý¿âÁ¬½Ó×Ö·û´®£¬Ò²ÊÇÈç´Ë ¡£ÉÏÍøËÑË÷£¬ÊÇÓпÉÄÜÊÇ comµÄÀà±ð×Ö ......

beginning python summary chapter 6 ³éÏó

1¡¢Ê¹ÓÃdef¶¨Ò庯Êý
2¡¢º¯ÊýÎĵµ£ºÔÚº¯ÊýµÄ¿ªÍ·Ð´ÏÂ×Ö·û´®£¬Ëü¾Í»á×÷Ϊº¯ÊýµÄÒ»²¿·Ö½øÐд洢£¬³ÆΪ"Îĵµ×Ö·û´®"¡£
                    ÄÚ½¨µÄ½Ð×öhelpµÄº¯Êý·Ç³£ÓÐÓÃ,Èç¹ûÄãÔÚ½»»¥Ê½½âÊÍÆ÷ÖÐʹÓã¬Äã¿ÉÒԵõ ......

pythonÄ£¿é

¼ò½é
ÄãÒѾ­Ñ§Ï°ÁËÈçºÎÔÚÄãµÄ³ÌÐòÖж¨ÒåÒ»´Îº¯Êý¶øÖØÓôúÂë¡£Èç¹ûÄãÏëÒªÔÚÆäËû³ÌÐòÖÐÖØÓúܶຯÊý£¬ÄÇôÄã¸ÃÈçºÎ±àд³ÌÐòÄØ£¿Äã¿ÉÄÜÒѾ­²Âµ½ÁË£¬´ð°¸ÊÇʹÓÃÄ£¿é¡£Ä£¿é»ù±¾ÉϾÍÊÇÒ»¸ö°üº¬ÁËËùÓÐÄ㶨ÒåµÄº¯ÊýºÍ±äÁ¿µÄÎļþ¡£ÎªÁËÔÚÆäËû³ÌÐòÖÐÖØÓÃÄ£¿é£¬Ä£¿éµÄÎļþÃû±ØÐëÒÔ.pyΪÀ©Õ¹Ãû¡£
Ä£¿é¿ÉÒÔ´ÓÆäËû³ÌÐò ÊäÈë ÒÔ±ãÀûÓÃËüµ ......

Python Áбí

Python Áбí
listÊÇ´¦ÀíÒ»×éÓÐÐòÏîÄ¿µÄÊý¾Ý½á¹¹£¬¼´Äã¿ÉÒÔÔÚÒ»¸öÁбíÖд洢һ¸ö ÐòÁÐ µÄÏîÄ¿¡£¼ÙÏëÄãÓÐÒ»¸ö¹ºÎïÁÐ±í£¬ÉÏÃæ¼ÇÔØ×ÅÄãÒªÂòµÄ¶«Î÷£¬Äã¾ÍÈÝÒ×Àí½âÁбíÁË¡£Ö»²»¹ýÔÚÄãµÄ¹ºÎï±íÉÏ£¬¿ÉÄÜÿÑù¶«Î÷¶¼¶À×ÔÕ¼ÓÐÒ»ÐУ¬¶øÔÚPythonÖУ¬ÄãÔÚÿ¸öÏîÄ¿Ö®¼äÓöººÅ·Ö¸î¡£
ÁбíÖеÄÏîÄ¿Ó¦¸Ã°üÀ¨ÔÚ·½À¨ºÅÖУ¬ÕâÑùPython¾ÍÖªµÀÄãÊ ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ