Get Immediate Subdirectories Using Python

Python

Returns a list containing the folder names of all immediate subdirectories below the current working directory.

 1|  import os
 2|  os.chdir(r'D:/Main/')
 3|  sub_dir = next(os.walk('.'))[1]
Did you find this snippet useful?

Sign up for free to to add this to your code library