tkinter 编写文件字符串替换,tkinter字符串,__author__ =
文章由Byrx.net分享于2019-03-23 06:03:21
tkinter 编写文件字符串替换,tkinter字符串,__author__ =
__author__ = 'muxiaoqing'import osimport ioclass ListRCFile(): """find all the file name is FliteStr you can use LoadFileList func to get the files who use FliteStr as postfix """ def __init__(self, DirectorPath, FliteStr): self.DirectorPath = DirectorPath; self.FliteStr = FliteStr self.filelist = [] def LoadFileList(self): for subdir, dirs, files in os.walk(self.DirectorPath): for file in files: if file[-len(self.FliteStr):] == self.FliteStr: self.filelist.append(subdir + '\\' +file) def LoadFliteFile(self, sflite, filsrc=[]): for file in self.filelist: with io.open(file, 'r+') as f: print file try: data = f.read() if(0 <= data.find(sflite)): filsrc.append(file) except: print 'read file '+ file + ' err!' f.close() def Replace(self, file, sSrc, sDesc): with io.open(file, 'r+') as f: try: data = f.read() data = data.replace(sSrc, sDesc) f.close() #write the data to file with io.open(file, 'w') as f: f.write(data) f.close() except: print 'read file '+ file + ' err!' f.close()""" for testf = ListRCFile(r'./', '.xml')files = []f.LoadFile(files)for file in files: print file"""
相关内容
- python通过ssh-powershell监控windows,,对于服务器的监控来说
- python 线程池,python线程,# !/usr/bin/
- python去除html标签,python去除标签,python去除html
- 保存芈月传的迅雷链接,保存芈迅雷链接,import urlli
- python生成随机密码或随机字符串,python生成字符串,py
- python阳历转换成阴历的代码,python阳历,#! -*- encod
- Python的时间转换,Python时间转换,要进行时间转换,在
- python正则提取CSV文件数据计算导购客单价.py,,'''pytho
- python datetime库使用代码详解,pythondatetime,python中对日期
- 删除windows 垃圾文件,删除windows垃圾,#coding:utf-
评论关闭