新聞中心
1、引入庫os,time,shutil。

在克州等地區(qū),都構(gòu)建了全面的區(qū)域性戰(zhàn)略布局,加強(qiáng)發(fā)展的系統(tǒng)性、市場前瞻性、產(chǎn)品創(chuàng)新能力,以專注、極致的服務(wù)理念,為客戶提供成都網(wǎng)站建設(shè)、做網(wǎng)站 網(wǎng)站設(shè)計(jì)制作定制開發(fā),公司網(wǎng)站建設(shè),企業(yè)網(wǎng)站建設(shè),成都品牌網(wǎng)站建設(shè),全網(wǎng)整合營銷推廣,成都外貿(mào)網(wǎng)站建設(shè)公司,克州網(wǎng)站建設(shè)費(fèi)用合理。
2、創(chuàng)建分類字典。
3、傳入桌面路徑。
將桌面路徑以字符串形式賦值給path,并將桌面所有文件名存入dirs。
4、在指定路徑創(chuàng)建文件夾用以保存分類文件。
5、判斷文件并進(jìn)行移動(dòng)分類。
6、程序打包為exe。
實(shí)例
import os,time,shutil
formats = {
"音頻":[".mp3",".wav"],
"視頻":[".mp4",".avi",".mov",".wmv",".asf",".rm",".rmvb"],
"圖片":[".jpeg",".jpg",".png",".gif",".bmp",".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)
for file in dirs:
fname,ext = os.path.splitext(file)
for d,exts in formats.items():
if ext in exts:
shutil.move(path+"\\"+file,filepath+"\\"+file)
print(ext)以上就是python電腦桌面中整理exe程序的方法,希望對(duì)大家有所幫助。更多Python學(xué)習(xí)指路:創(chuàng)新互聯(lián)Python教程
本文教程操作環(huán)境:windows7系統(tǒng)、Python 3.9.1,DELL G3電腦。
文章題目:創(chuàng)新互聯(lián)Python教程:python電腦桌面中整理exe程序
當(dāng)前路徑:http://m.fisionsoft.com.cn/article/dpjeepc.html


咨詢
建站咨詢
