#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个是不可以少的,如果少写一个或几个,就会报错
posted on 2014-07-10 17:36  小白闯天下  阅读(171)  评论(0编辑  收藏  举报