您的位置:首页 > 运维架构 > Linux

python delete only files in dir_Linux DB2 Java Python PHP Code Snippets_百度空间

2012-02-27 10:40 786 查看
python delete only files in dir_Linux DB2 Java Python PHP Code Snippets_百度空间

查看文章
python delete only files in dir2010-06-04 9:53
try:
for the_file in os.listdir(tmp_dir):
file_path = os.path.join(tmp_dir, the_file)
if os.path.isfile(file_path):
os.unlink(file_path)
os.rmdir(tmp_dir)#remove empty directory
except Exception, e:
pass
print "can not delete %s with directory inside: %s"%(tmp_dir,e)

内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐