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. (8)java基础知识-字符编码

    这块比较乱待整理... http://www.regexlab.com/zh/encoding.htm 字符编码 将各种文字.图形.标点.数字整合在一个集合叫做字符集. 把这些字符集按照不用规则进行编 ...

  2. KMP CF126B Password

    Description Asterix,Obelix和他们的临时伙伴Suffix.Prefix已经最终找到了和谐寺.然而和谐寺大门紧闭,就连Obelix的运气也没好到能打开它. 不久他们发现了一个字符 ...

  3. 小谈android/Linux rootkit(基于LKM)

    最近又学习了一下,感觉还有好多东西不知道,以后积累多一点再从新写一个. 在android上捣鼓了一下linux的内核rootkit,虽然中途遇到了无数坑,至今也没有完全写完,打算先好好啃一段时间lin ...

  4. nginx的location匹配

    http://www.cnblogs.com/lidabo/p/4169396.html 这个博主写的非常好 location: 先匹配普通location,再匹配正则表达式 1.而且选择了最大前缀匹 ...

  5. openfire源码修改后如何打包部署到linux服务器上

    原文:http://blog.csdn.net/jinzhencs/article/details/50457152 1.linux版本的3.10.3解压部署启动(过程略,参考我的另一篇博文http: ...

  6. andriod 读取通讯录

    package com.example.yanlei.wifi; import android.content.ContentResolver;import android.database.Curs ...

  7. 区别dependencies、devDependencies

    我们在使用npm install 安装模块或插件的时候,有两种命令把他们写入到 package.json 文件里面去,他们是: --save-dev 或 --save 首先需要说明的是Dependen ...

  8. ElasticSearch 专业术语

    1.Analysis(分析) 分析的过程就是将全文(full text)转换成 术语/分词(terms). 这取决于使用那个分析器,这些短语:“FOO BAR”, “Foo-Bar”, “foo,ba ...

  9. RPC接口mock测试

    转载:http://blog.csdn.net/ronghuanye/article/details/71124127 1        简介 Dubbo目前的应用已经越来越广泛.或者基于Dubbo二 ...

  10. 12. 改变JDK编译版本【从零开始学Spring Boot】

    spring Boot在编译的时候,是有默认JDK版本的,如果我们期望使用我们要的JDK版本的话,那么要怎么配置呢? 这个只需要修改pom.xml文件的<build>-- <plug ...