''' @Description: @Author: Sp4ce @Github: https://github.com/NS-Sp4ce @LastEditors: Sp4ce @Date: 2019-03-23 23:37:27 @LastEditTime: 2019-03-23 23:58:22 '''
import os def getFileExt(path): ''' 获取指定目录下的所有指定后缀的文件名 '''
f_list = os.listdir(path) for file in f_list: fileName=file file_ext=os.path.splitext(file)[-1] if file_ext == '.下载': reNameFileExt(fileName) def reNameFileExt(fileName): ''' 去除后缀''' newFileName = os.path.splitext(fileName)[0] oldFileName=path +'\\' +fileName changeFileName= path +'\\' +newFileName os.rename(oldFileName,changeFileName)
if __name__ == '__main__':
path = '' getFileExt(path)
|