码迷,mamicode.com
首页 > 其他好文 > 详细

批量该文件名

时间:2016-08-31 15:21:26      阅读:185      评论:0      收藏:0      [点我收藏+]

标签:

#!/usr/bin/python
import os
path1=‘/root/model/‘
file=os.listdir(path1)
num=file.index(‘index.html‘)
del file[num]
c=str(file)
c=c.replace(‘_‘,‘.‘)
c=c.title()
c=c.replace(‘Model.Php‘,‘class.php‘)
e=list(eval(c))
b=file
a=dict(zip(b,e))
for key in a.keys():
os.rename(os.path.join(path1,key),os.path.join(path1,a[key]))

批量该文件名

标签:

原文地址:http://www.cnblogs.com/yang68h/p/5825803.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!