python 文件重命名


將文件夾中的.jsp重命名為.html

import os

def rename(path):
    files = os.listdir(path)

    for file in files:
        dir = os.path.join(path, file)
    # 檢測是否為文件夾,如果是,則遞歸
if os.path.isdir(dir): rename(dir) continue file_split = file.split('.') if file_split[1] == "jsp": new_dir = os.path.join(path,file_split[0]+'.html') os.rename(dir,new_dir) rename(os.path.dirname(__file__))

 


免責聲明!

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



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