Skip to content

Latest commit

 

History

History
19 lines (16 loc) · 621 Bytes

常用小功能函数.md

File metadata and controls

19 lines (16 loc) · 621 Bytes

以二进制模式快速(利用mmap)搜索指定目录下所有文件

import os.path
import mmap

if __name__ == '__main__':
    base_dir = r"C:/ss/ss/sss"
    for path, dir_list, file_list in os.walk(base_dir):
        for file_name in file_list:
            full = os.path.join(path, file_name)
            if os.path.getsize(full) > 0:
                with open(full, "rb") as f:
                    mm = mmap.mmap(f.fileno(), 0,access=mmap.ACCESS_READ)
                    index = mm.find(b"QKvI4hJerufJ_1Qo")
                    if index>=0:
                        print("find bin:", full,index)