码迷,mamicode.com
首页 > 其他好文 > 详细

简单小练习_自动收集文件到文件夹

时间:2018-06-13 18:05:34      阅读:145      评论:0      收藏:0      [点我收藏+]

标签:class   for   style   move   收集   练习   files   listdir   exist   

import os
import shutil

path=./
files = os.listdir(path)

for f in files:
    folder_name = ./ + f.split(.)[-1]
    if not os.path.exist(path):
        os.makedirs(folder_name)
        shutil.move(f,folder_name)
    else:
        shutil.move(f,folder_name)

 

简单小练习_自动收集文件到文件夹

标签:class   for   style   move   收集   练习   files   listdir   exist   

原文地址:https://www.cnblogs.com/Erick-L/p/9178939.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!