best way to get files list of big directory on python?

后端 未结 9 1304
闹比i
闹比i 2021-02-07 22:36

I have insane big directory. I need to get filelist via python.

In code i need to get iterator, not list. So this not work:

os.listdir
glob.glob  (uses l         


        
9条回答
  •  长发绾君心
    2021-02-07 23:33

    for python 2.X

    import scandir
    scandir.walk()
    

    for python 3.5+

    os.scandir()
    

    https://www.python.org/dev/peps/pep-0471/

    https://pypi.python.org/pypi/scandir

提交回复
热议问题