python模糊搜索文件工具

2018年11月3日22:22:09 发表评论 1,348 views

这个可以搜索文件夹文件,下次开发个可以搜索子文件夹的东西。

 

 

import os
path = '/Users/cybermaster/Desktop/images'
files = os.listdir(path)

for f in files:
    if 'fish'in f and f.endswith('.png'):
        print(f)

发表评论

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen: