os.walkpythonos.walk?os.walk
os.walk(top[, topdown=True[, onerror=None[, followlinks=False]]])
top -- ?root?dirs?files?
1.root?
2.dirs?list?
3.files?list
topdown --Truetoptop?topdownTruewalktop?top
onerror -- callablewalk
followlinks -- ?Truelinux?symbolic link False? top?
#!/usr/bin/python
# -*- coding: UTF-8 -*-
import os
for root, dirs, files in os.walk(., topdown=False):
for name in files:
print(os.path.join(root, name))
for name in dirs:
print(os.path.join(root, name))
./.bash_logout
./amrood.tar.gz
./.emacs
./httpd.conf
./.tar.gz
./mysql.tar.gz
./test.py
./.bashrc
./.bash_history
./.bash_profile
./tmp
./tmp/test.py