将文件夹中的.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__))