标签:roo strip() odi getc import rip bsp split 去除
#!/usr/bin/env python # -*- coding: UTF-8 -*- import os import fnmatch def all_file(root, patterns=‘*‘, single_level=False, yield_folders=False): patterns = patterns.split(‘;‘) for path, subdirs, files in os.walk(root): if yield_folders: files.extend(subdirs) files.sort() for name in files: for pattern in patterns: if fnmatch.fnmatch(name, pattern.strip()): # 去除pattern两端的空格 yield os.path.join(path, name) if single_level: break if __name__ == ‘__main__‘: for path in all_file(os.getcwd(), ‘*.pyc‘): os.remove(path)
标签:roo strip() odi getc import rip bsp split 去除
原文地址:http://www.cnblogs.com/dockers/p/7513043.html