find_str.py
来源:互联网 发布:贵州大数据管理局 编辑:程序博客网 时间:2024/05/17 22:34
# -*- coding: cp936 -*-
import os
# 目的:查找一个目录下的包含指定字符串的文件
dir_name = raw_input("Please input the dir you want to find:/n")
find_str = raw_input("Please input the sting you want to find:/n")
def my_find(dir_name, find_str, results):
myfiles = os.listdir(dir_name)
for myfile in myfiles:
file_name = dir_name + "//" + myfile
if os.path.isfile(file_name):
f = open(file_name, 'r')
filer = f.read()
if(find_str in filer):
results.append(file_name)
f.close()
elif os.path.isdir(file_name):
my_find(file_name, find_str, results)
return results
results = []
results = my_find(dir_name, find_str, results)
for result in results:
print result
- find_str.py
- py
- py
- py
- py
- py
- py
- py
- Py
- bin2hex.py && hex2bin.py
- web.py (url.py)
- [py]py存放家具
- Xctf之调皮的py-py-py
- dir_size.py
- sendEmail.py
- Html.py
- web.py
- mail.py
- 移动游戏架构的艺术
- C#Excel2007和2003的链接字符串
- 【zz】[八卦故事]内核头文件传奇
- 将expression转换为数据类型int时发生算术溢出错误 解决
- Windows 2008 Server 密码获取攻略
- find_str.py
- Nutch在Windows中安装之细解
- 引用 Cache.Insert 与 Cache.Add 区别
- UDP 打洞原理
- 位运算应用口诀和实例
- linux 查看进程cpu和内存占用率排序
- 27款经典的CSS框架
- MultiselectItemSelector多选框
- ARM之汇编学习---如何编写ARM汇编程序