import os # 列出当前目录下所有的文件 os.chdir(r"\\Win-l4hi2f9h2r4\店铺数据\2016\花吉\10\media") files =os.listdir (r"\\Win-l4hi2f9h2r4\店铺数据\2016\花吉\10\media") for filename in files: portion = list(os.path.splitext(filename)) newname = portion[0] + ".jpg" os.rename(filename,newname)