# -*- coding: cp936 -*- import sys,os,string d=0; path="F://test" srcfile=os.listdir(path) for i in srcfile: src=path+"//"+i dst=path+"//"+str(d)+".txt" os.rename(src,dst) d=d+1; print src+"->"+dst