import os
def reName(dirname):
count = 0
for cur_file in os.listdir(dirname):
count += 1
oldDir = os.path.join(dirname, cur_file)
filetype = os.path.splitext(cur_file)[1] # 文件类型
newDir = os.path.join(dirname, str(count) + filetype) # 新文件
os.rename(oldDir, newDir)
print(oldDir, newDir)
if __name__ == "__main__":
dirname = r""#文件夹路径
reName(dirname)