代码如下
import os, re, string
path = "/Users/wanggeng/work/html/mygame/view/"
def ppp (path, file ):
if os.path.isfile (path + file ):
portion = os.path.splitext (file )
newname = portion[0] + ".html"
print (file, newname )
os.rename (path + file, path + newname )
print portion
else:
newpath = path + file + "/"
files = os.listdir (newpath )
for f in files:
ppp (newpath, f )
ppp (path, "")