python 绝技

来源:互联网 发布:外国域名注册商 编辑:程序博客网 时间:2024/05/04 04:32
#!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))
0 0