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)