os.walk examples

This commit is contained in:
Mert Gör ☭ 2023-09-06 19:35:54 +03:00
parent 5d1f116933
commit 173498f32b
No known key found for this signature in database
GPG Key ID: 2100A876D55B39B9
5 changed files with 44 additions and 0 deletions

20
python-temel/list.txt Normal file
View File

@ -0,0 +1,20 @@
/home/hwpplayer1/Documents
/home/hwpplayer1/Documents/iktisat
/home/hwpplayer1/Documents/cs
/home/hwpplayer1/Documents/revised
/home/hwpplayer1/Documents/pgp
/home/hwpplayer1/Documents/lkdtr
/home/hwpplayer1/Documents/cpp
/home/hwpplayer1/Documents/cv
/home/hwpplayer1/Documents/lisp
/home/hwpplayer1/Documents/translate-gnu-fsf
/home/hwpplayer1/Documents/text
/home/hwpplayer1/Documents/infra
/home/hwpplayer1/Documents/other
/home/hwpplayer1/Documents/other/jekyll_and_hyde_librivox_64kb_mp3
/home/hwpplayer1/Documents/rust
/home/hwpplayer1/Documents/git
/home/hwpplayer1/Documents/blog
/home/hwpplayer1/Documents/mastodon
/home/hwpplayer1/Documents/forum
/home/hwpplayer1/Documents/twitter

View File

@ -0,0 +1,9 @@
import os
try:
f = open('list.txt', 'w')
for root, dirs, files in os.walk('/home/hwpplayer1/Documents'):
f.write(root + '\n')
f.close()
except:
print('file cannot open!')

View File

@ -0,0 +1,9 @@
import os
try:
f = open('list.txt', 'w')
for root, dirs, files in os.walk('/'):
f.write(root + '\n')
f.close()
except:
print('file cannot open!')

3
python-temel/os.walk.py Normal file
View File

@ -0,0 +1,3 @@
import os
for root, dirs, files in os.walk('/'):
print(root)

3
python-temel/os.walk.py~ Normal file
View File

@ -0,0 +1,3 @@
import os
for root, dirs, files in os.walk('/'):
print(root)