标签:exists use std move spl for exist shu imp
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# @File : 文件分类.py
# @Author: Anthony.waa
# @Date : 2018/5/8 0008
# @Desc :
import os
import shutil
paths = ‘C:/Users/Administrator/Desktop/test/‘
files = os.listdir(paths)
list_dir = os.listdir(paths)
for f in files:
folder_name = paths + f.split(‘.‘)[-1]
if not os.path.exists(folder_name):
os.makedirs(folder_name)
shutil.move(paths + f,folder_name)
else:
shutil.move(paths + f,folder_name)
标签:exists use std move spl for exist shu imp
原文地址:https://www.cnblogs.com/ipyanthony/p/9009213.html