seq = 1 #计数器,从1开始 for file in files: os.rename(file, os.path.join(path, str(seq) + ". "+ file.split("\\")[-1])) #重命名文件 seq += 1