How to get all of the immediate subdirectories in Python

前端 未结 15 1640
旧时难觅i
旧时难觅i 2020-11-29 17:09

I\'m trying to write a simple Python script that will copy a index.tpl to index.html in all of the subdirectories (with a few exceptions).

I\'m getting bogged down

15条回答
  •  -上瘾入骨i
    2020-11-29 17:28

    Check "Getting a list of all subdirectories in the current directory".

    Here's a Python 3 version:

    import os
    
    dir_list = next(os.walk('.'))[1]
    
    print(dir_list)
    

提交回复
热议问题