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脚本语言也好。存在总有必然性,总有其价值。不管哪门你都没有资格去鄙视他。

posted on 2008-04-11 11:15 -274°C 阅读(3851) 评论(0)  编辑  收藏 所属分类: python

常用链接

留言簿(21)

随笔分类(265)

随笔档案(242)

相册

JAVA网站

关注的Blog

搜索

  •  

积分与排名

  • 积分 - 909102
  • 排名 - 40

最新评论