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

Ò»¸öPythonС½Å±¾ÔËÐг¬Âý

ÎÒÓÃPythonдÁËÒ»¸öС½Å±¾£¬×÷ÓÃÊÇͳ¼ÆÎÒe:\downloadĿ¼ÏÂÎļþ¶¼°üº¬ÁËÄÄЩÀ©Õ¹Ãû£¬²¢´òÓ¡³öÀ´£¬µ«ÊDz»ÖªµÀΪʲô£¬Õâ¸ö½Å±¾ËäÈ»¿ÉÒÔÕý³£µÄÔËÐУ¬µ«ÊÇÔËÐеķdz£·Ç³£Âý£¬Æ½¾ùÿһ´ÎÔËÐеÄʱ¼ä¶¼³¬¹ýÁË1·ÖÖÓ²ÅÓнá¹û£¬Çë½Ìһϸ÷λÕâÊÇΪʲô£¿ÊDz»ÊÇÎҵijÌÐòÄÄÀïÉè¼ÆµÄ²»ºÏÀíµ¼Öµģ¿

±¸×¢£º
ÎÒµÄe:\downloadĿ¼Ï£¬×ܹ²ÓÐ27103¸öÎļþ£¬1010¸öÎļþ¼Ð£¬×ܹ²´óС70G×óÓÒ¡£

´úÂëÈçÏ£º
Python code:

import os
import os.path
import re

path = 'e:/download/'
kzm = []
newKzm = []

for root,dirs,files in os.walk(path):
for file in files:
f = (os.path.join(root,file))
if '.' in f and re.search('\w{4}$',f):
var = f[-4:]
kzm.append(var)
elif '.' in f and re.search('\w{3}$',f):
var = f[-3:]
kzm.append(var)
elif '.' in f and re.search('\w{2}$',f):
var = f[-2:]
kzm.append(var)
for i in kzm:
if kzm.count(i) >= 2 and newKzm.count(i) ==0:
newKzm.append(i)
elif kzm.count(i) == 1:
newKzm.append(i)
print(newKzm)




ÒýÓÃ
ÊÔÊÔpythonÌṩµÄÏֳɷ½·¨...
Python codeimport os

path='e:/download/'
kzm= set()for root,dirs,filesin os.walk(path):for filein files:
ext= os.path.splitext(file)[1]
kzm.add(ext)print kzm


·Ç³£¸Ðл£¡È·Êµ±È


Ïà¹ØÎÊ´ð£º

PythonÖеÄUnicodeÔÚDelphiÈçºÎ»¹Ô­³ÉGb2312£¿

ÒÑÖªPython ÖУº
s = unicode("²âÊÔ", "gb2312")
s = u'\u6d4b\u8bd5'
print s
²âÊÔ

ÔÚDelphiÀïÃæÈçºÎ½«\u6d4b\u8bd5ÕâÑùµÄ»¹Ô­³ÉGb2312µÄºº×ÖÄØ£¿
ÕÒµ½¸ö·½·¨
......

python PILÄ£¿é´ò¿ªÍ¼Æ¬ÎÊÌâ

ÇëÎÊÏ£¬ÎÒµÄÊÇpython2.5°²×°ÁËPILÄ£¿é£¬È»ºó±àд³ÌÐò´ò¿ª±¾»úÉϵÄÒ»¸öͼƬʱ£¬ÎªÊ²Ã´ÀϳöÏÖ´íÎóÄØ£¬ÀÏÊÇÕÒ²»µ½Í¼Æ¬£¬´íÎóÌáʾÈçÏ£ºFile "C:\Python25\Lib\site-packages\PIL\Image.py", line 1888, in o ......

pythonÕýÔò±í´ïʽ ÈçºÎÈ¡³öÒÔÏÂ×Ö·û´® ¶àл

s='aaa111aaa,bbb222,333ccc,444ddd444,555eee666,fff777ggg'
ÓÃÕýÔò±í´ïʽȡ³ö ǰºó×ÖĸÏàͬµÄÊý¾Ý ½á¹ûÈçÏÂ:
111 ddd
лл~
Python code:

import re
s='aaa111aaa,bbb222,333ccc,444ddd444,555eee666,ff ......

ÓôÃÆ£¬python 0d0a»»ÐÐÎÊÌâ

import os,sys,zipfile
teststr = open('1.txt').read()
zipFile = zipfile.ZipFile('test.zip','w')
zipFile.writestr('test.txt',teststr)
zipFile.close()

É ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØÍ¼ | ¸ÓICP±¸09004571ºÅ