Python读取文件文件夹并检索
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读取文件文件夹并检索的更多相关文章
- Python读取txt文件
Python读取txt文件,有两种方式: (1)逐行读取 data=open("data.txt") line=data.readline() while line: print ...
- Python读取Yaml文件
近期看到好多使用Yaml文件做为配置文件或者数据文件的工程,随即也研究了下,发现Yaml有几个优点:可读性好.和脚本语言的交互性好(确实非常好).使用实现语言的数据类型.有一个一致的数据模型.易于实现 ...
- python读取中文文件编码问题
python 读取中文文件后,作为参数使用,经常会遇到乱码或者报错asii错误等. 我们需要对中文进行decode('gbk') 如我有一个data.txt文件有如下内容: 百度 谷歌 现在想读取文件 ...
- Python读取SQLite文件数据
近日在做项目时,意外听说有一种SQLite的数据库,相比自己之前使用的SQL Service甚是轻便,在对数据完整性.并发性要求不高的场景下可以尝试! 1.SQLite简介: SQLite是一个进程内 ...
- Python读取xlsx文件
Python读取xlsx文件 脚本如下: from openpyxl import load_workbook workbook = load_workbook(u'/tmp/test.xlsx') ...
- Python 读取WAV文件并绘制波形图
aa Python 读取WAV文件并绘制波形图 ffmpeg -i test_pcm_mulaw.wav -f wav -codec:a pcm_s16le -ar 8000 -ac 1 out.wa ...
- 使用python读取yaml文件
在做APP测试时,通常需要把参数存到一个字典变量中,这时可以将参数写入yaml文件中,再读取出来. 新建yaml文件(android_caps.yaml),文件内容为: platformName: A ...
- python 读取bin文件
python读取bin文件并下发串口 # coding:utf-8import time, serialfrom struct import *import binascii file = ope ...
- 记录:python读取excel文件
由于最近老是用到python读取excel文件,所以特意记录一下python读取excel文件的大体框架. 库:xlrd(读),直接pip安装即可.想要写excel文件的话,安装xlwd库即可,也是直 ...
- 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 ...
随机推荐
- 「kuangbin带你飞」专题二十 斜率DP
layout: post title: 「kuangbin带你飞」专题二十 斜率DP author: "luowentaoaa" catalog: true tags: mathj ...
- Apache CXF实战之四 构建RESTful Web Service
Apache CXF实战之一 Hello World Web Service Apache CXF实战之二 集成Sping与Web容器 Apache CXF实战之三 传输Java对象 这篇文章介绍一下 ...
- Codeforces Round #535 (Div. 3) [codeforces div3 难度测评]
hhhh感觉我真的太久没有接触过OI了 大约是前天听到JK他们约着一起刷codeforces,假期里觉得有些颓废的我忽然也心血来潮来看看题目 今天看codeforces才知道居然有div3了,感觉应该 ...
- 阅读 Android源码的一些姿势
日常开发中怎么阅读源码 找到正确的源码 IDE 是日常经常用的东西,Eclipse 就不说了,直接从 Android Studio(基于 IntelliJ Community 版本改造)开始. 我们平 ...
- Android 使用SQLite本地数据库
参考:http://blog.csdn.net/jianghuiquan/article/details/8569252 在Android平台上,集成了一个嵌入式关系型数据库—SQLite.以SQLi ...
- codeigniter与swfupload完整解决方案
转自:http://blog.sina.com.cn/s/blog_6d8dc8eb0100s4bv.html codeigniter(简称ci)有研究了一段时间了,看重的是ci的轻量,便捷,最近公司 ...
- windows上的docker容器内安装vim
Reading package lists... Done Building dependency tree Reading state information... Done E: Unable t ...
- 修改Tomcat标题栏内容
你是否遇到过在一个OS任务栏中同时打开多个Tomcat启动程序窗口,这种情况下你会无法区分具体是哪个窗口启动哪个程序,以下方式可以实现Bat启动程序标题栏自定义. 打开Tomcat的Bin目录中,打开 ...
- [转载]使用expect实现shell自动交互
FROM:http://www.nginx.cn/1934.html shell脚本需要交互的地方可以使用here文档是实现,但是有些命令却需要用户手动去就交互如passwd.scp 对自动部署免去用 ...
- [PWA] Cache JSON Data in a React PWA with Workbox, and Display it while Offline
We can view the PWA offline because we are caching the static and CDN assets for the app - but the l ...