0
How can i list all and every directory on my PC .py
6 ответов
+ 2
Well python CA just browse a whole drive just use the glob utility
import glob
print (glob.glob(#drive-letter:/*/**/*.* recursive=true)
+ 1
I mean, you kinda can...use the os library
https://code.sololearn.com/calheDiLtdJE/?ref=app
+ 1
Thank you
0
U possibly can't
0
Thank you
0
Maybe this will help. Define a command line and send it to the operating system.
#*NIX recursive dir command
dircmd = "ls -RaF /"
#MSDOS version
#dircmd = "tree /F C:/"
import os
os.system(dircmd)
If you want to work with the names in memory you could redirect the output to a file and load the file into memory.
import os
os.system(dircmd + " >dir.txt")
f = open("dir.txt", "r")
l = list(f)
f.close()
print(l)