python遍历文件夹下的所有文件

# 遍历文件夹下的所有文件
import os

def readDictionary(dictoryName):
    for filename in os.listdir(dictoryName):
        filepath = os.path.join(dictoryName, filename)
        if os.path.isdir(filepath):
            readDictionary(filepath)
        else:
            print(filepath)

if __name__=="__main__":
    dictionaryName = "C:\\Users\\Administrator\\Desktop\\resources"
    readDictionary(dictionaryName)

 

posted @ 2024-02-28 19:29  江湖凶险  阅读(27)  评论(0编辑  收藏  举报