【python創建文件夾】python創建文件夾


【參考】

https://www.cnblogs.com/hushaojun/p/4533241.html

https://www.cnblogs.com/monsteryang/p/6574550.html

 

 

【實踐】

# -*- coding:utf-8 -*-
import os

# 讀取目錄下文件列表
v_foleder='D:/aaa1/bbb1/hug'
Vname_list=os.listdir(v_foleder)
print Vname_list

# 指定路徑創建新文件夾
v_name='ccc_hug'
folder_name='img_'+v_name
file_path='D:/aaa1/bbb1/'+folder_name

if not os.path.exists(file_path): # 判斷文件夾是否已經存在    
    os.mkdir(file_path)
    print file_path + ' 創建成功'
else:
    print file_path + ' 目錄已存在'

 

 

 

 

 

【其他/補充】

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM