當前位置:編程學習大全網 - 網站源碼 - python os.walk

python os.walk

python os.walk?

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

  • 上一篇:為什麽我打開cf時會出現應用程序錯誤0x0000000?指令引用的0x00000000內存。無法讀取內存。
  • 下一篇:如何做網站?
  • copyright 2024編程學習大全網