📜  遍历python代码示例中的目录

📅  最后修改于: 2022-03-11 14:45:55.305000             🧑  作者: Mango

代码示例1
import os

dir = os.fsencode(filename='img') # here 'img' should be replaced with
                                    # desired directory

lst = []

for items in os.listdir(dir):
    lst.append(items)
print(lst)