首页 / 知识

python电脑桌面中整理exe程序

2023-11-12 12:58:00

python电脑桌面中整理exe程序

1、引入库os,time,shutil。

2、创建分类字典。

3、传入桌面路径。

将桌面路径以字符串形式赋值给path,并将桌面所有文件名存入dirs。

4、在指定路径创建文件夹用以保存分类文件。

5、判断文件并进行移动分类。

6、程序打包为exe。

实例

importos,time,shutil

formats={

"音频":[".mp3",".wav"],

"视频":[".mp4",".avi",".mov",".wmv",".asf",".rm",".rmvb"],

"图片":[".webp",".webp",".webp",".webp",".webp",".psd",".html"],

"文档":[".txt",".pdf",".doc",".docx",".xlsx",".pptx"],

"压缩":[".zip",".rar",".7z",".jar"],

}

path="D:\\桌面"

dirs=os.listdir(path)

filename="桌面缓冲文件"+time.strftime('%Y:%m:%d',time.localtime(time.time())).replace(":","_")

filepath="D:\\Source_SBUF\\"+filename

os.mkdir(filepath)

forfileindirs:

fname,ext=os.path.splitext(file)

ford,extsinformats.items():

ifextinexts:

shutil.move(path+"\\"+file,filepath+"\\"+file)

print(ext)

以上就是python电脑桌面中整理exe程序的方法,希望对大家有所帮助。更多Python学习教程请关注我们

培训图片程序电脑桌面赋值

最新内容

相关内容

热门文章

推荐文章

标签云

猜你喜欢