gpt4 book ai didi

python - 使用 Python 快速查找文件的独立于操作系统的方法

转载 作者:太空宇宙 更新时间:2023-11-04 00:42:20 25 4
gpt4 key购买 nike

使用 Python,如何在目录(包括子目录)中快速搜索文件?

此处的标准答案使用 os.walk(),如果在 Linux 下工作,它比仅调用 find/path -iname "*string*" 慢.

是否有一种干净的独立于平台的方法来实现更快的速度?

最佳答案

os.scandir (GitHub)os.walk 快并且是 now in the Python 3.5+ standard library.

关于python - 使用 Python 快速查找文件的独立于操作系统的方法,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41357056/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com