本来是准备做平台插件用的 结果没动力往下做了 这是一部分代码 # -*- coding: GBK-*- import glob import os import re print(''' ◥█▄▃▁ . ☆ ..◥█☆█▅▄▃▁▁▁▁▁▁▁▃▄▅00▅▄▁ ☆ 〓▇█████ ████████████▅▄▃▁▁▁▁▁ -- -- 〓〓〓████████████████.║内容筛选小工具 ☆ ---- 帅选小工具V1.0 ''') # 打开一个文本提取筛选内容 def ope(): txt=open('1.txt','r') while 1: line = txt.readline() print line if line=='': break txt.close() # 遍历所有文件夹返回路径的函数 def txt(): for root,dirs,files in os.walk(path): for fn in files: string=re.search(che,fn) if string != None: print root+'\\'+fn # 输出图片路径 # 车号查找 --------------------------------------------------------------------- def ch(): path='图片' che=raw_input('请输入要查找的车号:') # 创建一个名单的文件夹 ''' title=('名单') new_path=os.path.join(path,title) if not os.path.isdir(new_path): os.makedirs(new_path) ''' txt=open('1.txt','r') lists=(txt.read()) num=0 if che in lists: print '\n在名单内!!!!!!!!!!!!!\n' else: print '\n不在 \n' txt.close() # 统计txt中一共有多少行 num = 0 count=0 f = open('1.txt','r') for x in f: count+=1 f.close() # 查找匹配内容 f = open('1.txt','r') while 1: line = f.readline() string = re.search(che,line) num += 1 if string != None: print "%d : %s"%(num,line+'\n') if num==count: break f.close() # txt() for root,dirs,files in os.walk(path): for fn in files: string=re.search(che,fn) if string != None: print '图片路径:'+root+'\\'+fn+'\n' # 输出图片路径 while 1: ch() |