Python3在指定路径下递归定位文件中出现的字符串
[本文出自天外归云的博客园] 脚本功能:在指定的路径下递归搜索,找出指定字符串在文件中出现的位置(行信息)。 用到的python特性: 1. PEP 318 -- Decorators for Functions and Methods 2. PEP 380 -- Syntax for Delegating to a Subgenerator 3.PEP 471 -- os.scandir() function -- a better and faster directory iterator 4.PEP 498 -- Literal String Interpolation 代码如下: import os import sys __all__ = ['DirPath'] ''' 在指定路径下递归查找包含指定字符串的文件 可以指定查找的文件类型category-默认为'.py' 可以指定查找的字符串str-默认为'python' ''' class DirPath(object): # 初始化参数查找路径-path def __init__(self, path): self.show...