[请大家提意见]各种意见,甚至代码风格。
时间:2011-11-15
来源:互联网
我写Python不够专业,但是想深造。
各位多提意见,不管是风格,还是什么。多谢了。200分酬谢大家。
Python code
各位多提意见,不管是风格,还是什么。多谢了。200分酬谢大家。
Python code
import os import shutil def get_exclude_files(fn): excluded_files = [] file = open(fn) excluded_files = file.readlines() file.close() return excluded_files def remove_unused_file(file): for ext in ['.ncb', '.exe', '.ilk', '.pdb', '.obj', '.idb', '.user', '.aps', '.dep', '.pch', '.res', '.suo']: if (file.endswith(ext)): os.remove(file) def remove_dir_files(cur): count = 0 files = os.listdir(cur) excluded = os.path.join(cur, "exclude.files") excluded_files = [] if (os.path.exists(excluded)): excluded_files = get_exclude_files(excluded) for fn in files: if (fn in excluded_files): continue file = os.path.join(cur, fn) print(file) if os.path.isfile(file): remove_unused_file(file) else: paths = os.listdir( cur ) count += remove_dir_files(file) return count def main(): count = remove_dir_files(os.getcwd()) print(count) if __name__ == '__main__': main()
作者: healer_kx 发布时间: 2011-11-15
哦,这个是用于删除某个目录下,特定扩展名的文件的小程序。
作者: healer_kx 发布时间: 2011-11-15
相关阅读 更多
热门阅读
-
office 2019专业增强版最新2021版激活秘钥/序列号/激活码推荐 附激活工具
阅读:74
-
如何安装mysql8.0
阅读:31
-
Word快速设置标题样式步骤详解
阅读:28
-
20+道必知必会的Vue面试题(附答案解析)
阅读:37
-
HTML如何制作表单
阅读:22
-
百词斩可以改天数吗?当然可以,4个步骤轻松修改天数!
阅读:31
-
ET文件格式和XLS格式文件之间如何转化?
阅读:24
-
react和vue的区别及优缺点是什么
阅读:121
-
支付宝人脸识别如何关闭?
阅读:21
-
腾讯微云怎么修改照片或视频备份路径?
阅读:28