The below snippet returns all the folders and it's sub-directories
for r, d, f in os.walk('/tmp/'):
for folder in d:
print folder
What I need is only the folders inside the current folder /tmp/
Version: Python 2.7
The below snippet returns all the folders and it's sub-directories
for r, d, f in os.walk('/tmp/'):
for folder in d:
print folder
What I need is only the folders inside the current folder /tmp/
Version: Python 2.7
os.walk('/tmp/').next()[1]
lists all the folders inside the current directory
for folder in os.walk('/tmp/').next()[1]:
print folder