Ò׽ؽØͼÈí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö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


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


Ïà¹ØÎÊ´ð£º

eric4ÔõôÔËÐÐpython³ÌÐò£¿

pythonºÍpyqtÒÔ¼°Eric4¶¼ÒѾ­ÅäÖúÃÁË£¬´ò¿ªEric4д¸öpython³ÌÐò±ÈÈç¼òµ¥µÄ
print¡°hello£¬world¡±£¬Ôõô±àÒëÔËÐÐÁË£¬Start²Ëµ¥µÄËùÓÐÃüÁ³öÏÖºÍͼÖв¶àµÄ¶Ô»°¿ò£¬Ó¦µ±ÔõôÔËÐÐÁË£¿

Çó´ó¼ÒÖ¸½Ì

ûÓÐÈËÓà ......

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

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

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

python urllib urllib2 httplib ·ÃÎÊurlµÄÎÊÌâ

ÎÒÏëÓÃpython½âÎöÍøÒ³ÖеÄurl ÔÚÏÂÔØ֮ǰ, ÎÒÏëÏÈ·¢Ò»¸öheadÇëÇó ²»ÐèÒªÏÂÔØÕû¸öÍøÒ³, ÏÈ»ñµÃ¸ÃÍøÕ¾µÄheadÐÅÏ¢, ¶ÁȡһЩÐÅÏ¢Ö®ºó ÔÚµ÷ÓÃÕâЩ¿âµÄread·½·¨À´¶ÁÈ¡Õû¸öÍøÒ³ ¸ÃÔõô²Ù×÷ÄØ ¶àл
°ï¶¥ÁË

ÓÐÈËÄÜÖ¸½ÌÒ» ......

ÓôÃÆ£¬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ºÅ