code
来源:互联网 发布:ipad3软件更新打不开 编辑:程序博客网 时间:2024/06/05 05:32
# -*- coding: cp936 -*-
import os,stat
def purge(path):
if not os.path.exists(path):
return 'Folder does not exists!';
count = 0;
for item in os.listdir(path):
subpath = os.path.join(path, item);
mode = os.stat(subpath)[stat.ST_MODE];
if stat.S_ISDIR(mode):
count += purge(subpath);
else:
os.chmod(subpath, stat.S_IREAD|stat.S_IWRITE);
os.unlink(subpath);
count += 1;
try:
os.rmdir(path);
except:
print '删除目录%s失败' % path
pass
count += 1;
return count;
def list_all(path):
fl = os.listdir(path)
for ff in fl:
if ff == 'as':
continue
if not os.path.isfile(os.path.join(path,ff)):
print 'DEL DIR:',ff
purge(os.path.join(path, ff))
else:
print 'DEL FILE:',ff
os.remove(os.path.join(path,ff))
list_all('c:\\abc')
- code
- code
- code
- code
- Code
- code
- code
- Code
- Code
- CODE
- code
- code
- code
- code
- code
- code
- Code
- code
- java 彻底理解 byte char short int float long double
- 某某
- 水晶报表动态列
- 使用ErrorProvider改善用户体验
- SQL Server数据库查询速度慢的原因和解决方法
- code
- SMTP服务器发送邮件:入门级
- Keycode表
- android-sdcard路径
- setNeedsDisplay和layoutSubViews
- 自动化测试Web服务器性能 autobench+httperf
- 正负数二进制计算
- i节点(inode)和文件描述符(file descriptor)的区别和联系
- 百万数据查询优化技巧三十则