标签:pre nbsp lis move file color folder std import
以下代码将指定目录下的所有文件分类,按照后缀名归类存储
import os import shutil path = ‘./‘ def foo(): files = os.listdir(path) for f in files: folder = path + f.split(‘.‘)[-1] if not os.path.exists(folder): os.makedirs(folder) shutil.move(f, folder) if __name__ == ‘__main__‘: foo()
标签:pre nbsp lis move file color folder std import
原文地址:https://www.cnblogs.com/zhangjian0092/p/12331082.html