【问题标题】:Listing files recursively递归列出文件
【发布时间】:2016-07-30 06:59:04
【问题描述】:

使用 Python,如何仅获取当前文件夹及其子文件夹的名称?

【问题讨论】:

  • 向我们展示您迄今为止所做的努力。这不是免费的代码编写服务。

标签: python directory


【解决方案1】:
import os
for root, dirs, files in os.walk(".", topdown=False):
    for name in files:
        print(os.path.join(root, name))
    for name in dirs:
        print(os.path.join(root, name))

【讨论】:

    猜你喜欢
    • 2011-01-04
    • 2018-05-14
    • 2017-11-17
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-05-07
    • 2021-03-21
    • 2010-10-19
    相关资源
    最近更新 更多