import os
import os.path f=open("Shouldlist.txt")
ShouldList=[]
while 1:
line =f.readline().strip('\n')
# print line
if not line:
break
ShouldList.append(line)
# print ShouldList rootdir="Z:\GETOT_BW" ArriveFile='' for parent,dirnames,filenames in os.walk(rootdir):
ArriveFile=' '.join(filenames) # print ArriveFile ArriveNumber=0 for Item in ShouldList:
if(ArriveFile.find(Item)>0):
ArriveNumber+=1
else:
pass print ArriveNumber #print ShouldList[1]
#print ArriveFile[254:274]

此段代码主要是检索特定文件夹的全部文件,并对其进行检測,推断是否应到的file到到了。

Python读取文件文件夹并检索的更多相关文章

  1. Python读取txt文件

    Python读取txt文件,有两种方式: (1)逐行读取 data=open("data.txt") line=data.readline() while line: print ...

  2. Python读取Yaml文件

    近期看到好多使用Yaml文件做为配置文件或者数据文件的工程,随即也研究了下,发现Yaml有几个优点:可读性好.和脚本语言的交互性好(确实非常好).使用实现语言的数据类型.有一个一致的数据模型.易于实现 ...

  3. python读取中文文件编码问题

    python 读取中文文件后,作为参数使用,经常会遇到乱码或者报错asii错误等. 我们需要对中文进行decode('gbk') 如我有一个data.txt文件有如下内容: 百度 谷歌 现在想读取文件 ...

  4. Python读取SQLite文件数据

    近日在做项目时,意外听说有一种SQLite的数据库,相比自己之前使用的SQL Service甚是轻便,在对数据完整性.并发性要求不高的场景下可以尝试! 1.SQLite简介: SQLite是一个进程内 ...

  5. Python读取xlsx文件

    Python读取xlsx文件 脚本如下: from openpyxl import load_workbook workbook = load_workbook(u'/tmp/test.xlsx') ...

  6. Python 读取WAV文件并绘制波形图

    aa Python 读取WAV文件并绘制波形图 ffmpeg -i test_pcm_mulaw.wav -f wav -codec:a pcm_s16le -ar 8000 -ac 1 out.wa ...

  7. 使用python读取yaml文件

    在做APP测试时,通常需要把参数存到一个字典变量中,这时可以将参数写入yaml文件中,再读取出来. 新建yaml文件(android_caps.yaml),文件内容为: platformName: A ...

  8. python 读取bin文件

    python读取bin文件并下发串口   # coding:utf-8import time, serialfrom struct import *import binascii file = ope ...

  9. 记录:python读取excel文件

    由于最近老是用到python读取excel文件,所以特意记录一下python读取excel文件的大体框架. 库:xlrd(读),直接pip安装即可.想要写excel文件的话,安装xlwd库即可,也是直 ...

  10. Python读取CSV文件,报错:UnicodeDecodeError: 'gbk' codec can't decode byte 0xa7 in position 727: illegal multibyte sequence

    Python读取CSV文件,报错:UnicodeDecodeError: 'gbk' codec can't decode byte 0xa7 in position 727: illegal mul ...

随机推荐

  1. slice,splice,substr,substring函数的区别

    slice: 语法:array.slice(startIndex,endIndex); 参数: startIndex:必须,规定从何处开始选取,如果为负则从尾部开始计算 : endIndex:可选,规 ...

  2. UpdateLayeredWindow后,使用Gdi DrawText文字透明的解决办法

    来源:http://stackoverflow.com/questions/5309914/updatelayeredwindow-and-drawtext 要点就是在先在memDc DrawText ...

  3. poj3311(状态压缩DP)

    poj3311 题意 给出一个矩阵,i 行 j 列表示位置 i 到 j 的时间. 求从 0 点出发经过 1 到 n 所有点后并返回 0 点最短耗时. 分析 先用 Floyd 算法,求出两点之间最短路, ...

  4. 1424 零树 (树形DP)

    1424 零树 题意 给出一棵树,每次可以选择一个包含节点 1 的连通块,将所有的节点的权值同时加 1 或减 1 ,问最少多少次操作使所有节点权值变为 0 . 分析 这种题意简单的题目好处就是能很快知 ...

  5. Topcoder 刷题之路_鶸的奋斗

    最近碰到的题不是水题就是坑题,实在没意思,听说神犇们都在Topcoder上刷SRM,于是我决定将SRM的DIV 1刷个遍.这里是目录 哎..好多转博客不注明出处的,这里给出本博客的出处:http:// ...

  6. 如何隐藏 video 元素的下载按钮

    1. 使用 video 元素的 ControlList API <video controls controlsList="nodownload"></video ...

  7. JQuery插件开发格式

    原地址 一.jQuery扩展 1.$.extend(object) 类似于.Net的扩展方法,用于扩展jQuery.然后就可以用$.的方式调用. $(function(){ $.extend({ fu ...

  8. 关于C++中_finite()函数的说明 [转]

    The function int _finite(double x) returns 1 (true) if x is an ordinary number and 0 (false) if x is ...

  9. 智能选择器和语义化的CSS

    本文由白牙根据Heydon Pickering的<Semantic CSS With Intelligent Selectors>所译,整个译文带有我自己的理解与思想,如果译得不好或不对之 ...

  10. jstl fn:replace替换换行符

    textarea输入换行符后应该是'\n',在div中展示时替换成'<br>' 找到一种方法用jsp标签 jstl fn:replace方法 使用fn:replace方法之前 先要把jst ...