#!ur/bin/env python
#coding:utf8
#文件重命名


import os 

for file in os.listdir("."):
    if os.path.splitext(file)[1] == ".tmp":#后缀
        print file
        os.rename(file, os.path.splitext(file)[0] + ".jpg")#前缀


print 'done!'
#!usr/bin/env python
#coding:utf8
#批量生产txt文件
#



def createtxt(count):
    for i in range(count):
        f = open(str(i+1)+'.txt', 'w+')
        f.write("页面访问成功\n"+str(i))
        f.close()
        print 'done--'+str(i+1)





if __name__ == '__main__':
    count = raw_input('enter the number to create txt: ')
    createtxt(int(count))
Logo

CSDN联合极客时间,共同打造面向开发者的精品内容学习社区,助力成长!

更多推荐