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. #请用索引取出下面list的指定元素:

    #!/usr/bin/python # -*- coding: utf-8 -*- L = [ ['Apple', 'Google', 'Microsoft'], ['Java', 'Python', ...

  2. nginx+tomcat负载使用

    Nginx+Tomcat搭建 版本 操作系统版本 Centos 6.4 Nginx版本 nginx-1.3.15.tar.gz JDK版本 jdk-7u71-linux-i586   //jdk1.7 ...

  3. Java多线程中的异常处理

    在java多线程程序中,所有线程都不允许抛出未捕获的checked exception,也就是说各个线程需要自己把自己的checked exception处理掉.这一点是通过java.lang.Run ...

  4. [BZOJ3569]DZY Loves Chinese II(随机化+线性基)

    3569: DZY Loves Chinese II Time Limit: 5 Sec  Memory Limit: 64 MBSubmit: 1515  Solved: 569[Submit][S ...

  5. jdbc多种实现方式

    1,驱动加载 //注册驱动 //DriverManager.registerDriver(new Driver());此方法被淘汰 Class.forName("com.mysql.jdbc ...

  6. pr_debug、dev_dbg等动态调试一

    内核版本:Linux-3.14 作者:彭东林 邮箱:pengdonglin137@163.com pr_debug: #if defined(CONFIG_DYNAMIC_DEBUG) /* dyna ...

  7. Nand 的几个名词:oob,bbt,ecc

    转:http://blog.csdn.net/lanmanck/article/details/4230904 例如Samsung K9F1208U0B,数据存储容量为64MB,采用块页式存储管理.8 ...

  8. vi中使用“/”查找字符

    在vi 文件中使用"/"查找字符串 命令模式下,输入 /word 后回车,即查找word,按 n 查找下一个匹配单词,按 N 查找上一个匹配单词.

  9. django 分页django-pure-pagination

    虽然django自带了一个paginator,但不是很方便,我们使用django-pure-pagination github地址https://github.com/jamespacileo/dja ...

  10. Lock flag DX

    https://msdn.microsoft.com/en-us/library/windows/desktop/bb322846(v=vs.85).aspx discard nooverwrite ...