Twitter iPhone pliant OnePlus 11 PS5 Disney+ Orange Livebox Windows 11

lister arborescence repertoire

1 réponse
Avatar
vincent daanen
bonjour !

je souhaite lister l'arborescence d'un repertoire. Pour cela, j'ai ecrit
ceci :

for root,dirs,files in os.walk('.'):
for l_dir in dirs :
print join(root,l_dir);

dont le resultat est :
.\DLLs
.\Doc
.\include
.\Lib
.\libs
.\tcl
.\Tools
.\Lib\bsddb
.\Lib\compiler
[cut]
.\tcl\dde1.2
.\tcl\reg1.1
.\tcl\tcl8.4
[cut]
.\tcl\tcl8.4\encoding
.\tcl\tcl8.4\http1.0
.\tcl\tcl8.4\http2.4
.\tcl\tcl8.4\msgcat1.3
[cut]
.\Tools\i18n
.\Tools\pynche
.\Tools\PyQt-3.1.2

Ce que je voudrais, c'est plutot quelquechose du genre
.\DLLs
.\Doc
.\include

.\Lib
.\Lib\bsddb
.\Lib\compiler

.\libs

.\tcl
.\tcl\dde1.2
.\tcl\reg1.1
.\tcl\tcl8.4
.\tcl\tcl8.4\encoding
.\tcl\tcl8.4\http1.0
.\tcl\tcl8.4\http2.4
.\tcl\tcl8.4\msgcat1.3

.\Tools
.\Tools\i18n
.\Tools\pynche
.\Tools\PyQt-3.1.2

faut-il que je le fasse 'a la main' ou y a-t-il un moyen de parametrer
os.walk (ou la boucle for) pour obtenir cela !

Merci

Vince

1 réponse

Avatar
Michel Claveau - abstraction méta-galactique non triviale en fuite perpétuelle.
Bonsoir !

Enregistre les données dans une liste, puis, à la fin, tri cette liste,
avant de l'afficher.