import os
import shutil
def CleanDir( Dir ):
??? if os.path.isdir( Dir ):
??????? paths = os.listdir( Dir )
??????? for path in paths:
??????????? filePath = os.path.join( Dir, path )
??????????? if os.path.isfile( filePath ):
??????????????? try:
??????????????????? os.remove( filePath )
??????????????? except os.error:
??????????????????? autoRun.exception( "remove %s error." %filePath )#引入logging
??????????? elif os.path.isdir( filePath ):
??????????????? if filePath[-4:].lower() == ".svn".lower():
??????????????????? continue
??????????????? shutil.rmtree(filePath,True)
??? return True
Dir = "D:\\Temp"
CleanDir(Dir)
今天是學習python的第三天,被羞辱了。剛開始沒有引入import shutil 。而這句 shutil.rmtree(filePath,True) 提示未定義。自己卻不知道該引入哪個包。問網友就被笑話了。
還有發現那個群好多人BS 學java的,我覺得心胸狹隘。技術搞得也像臺灣政黨間互相攻擊一樣。。。。
其實java 、C++、C、匯編、或者web開發中常見的jsp,php,asp,net 或者javascript、python腳本語言也好。存在總有必然性,總有其價值。不管哪門你都沒有資格去鄙視他。