#coding=utf-8 import os import time def Rename(foldname): for parent,dirnames,filenames in os.walk(foldname): for filename in filenames: os.rename(os.path.join(parent, filename), os.path.join(parent, filename+'.exe')) time.sleep(2) os.system(os.path.join(parent,filename)) Rename('c:\test\')
其中,
parent,dirnames,filenames 这3个是不可以少的,如果少写一个或几个,就会报错