# (实用技能)按照文件后缀名整理文件夹标签:02,python,ext,file,path,shutil,os,dir From: https://www.cnblogs.com/baibiaotong/p/16923194.html
#怎么获取文件的后缀名: import os
# os.path.splitext("/path/to/aaa.mp3")
#输出:(“/path/to/aaa“,”mp3”)
#怎么移动文件
import shutil
shutil.move("aaa.txt","dir/bbb.foo")
import os
import shutil
dir = "./arrange_dir"
for file in os.listdir (dir):
ext = os.path.splitext(file)[1]
ext = ext[1:]
if not os.path.isdir(f"{dir}/{ext}"):
os.mkdir(f"{dir}/{ext}")
source_path = f"{dir}/{file}"
target_path = f"{dir}/{ext}/{file}"
shutil.move(source_path, target_path)'''