Python os.walk() 笔记

我们先使用如下代码:

import os

path = 'Path_file'
for i in os.walk(path):
	print(i)
# ("当前文件夹的地址", "当前文件夹下的文件夹名称", "当前文件夹下的文件,不包含子目录文件")

获得的输出结果:

('Path_file', ['Tester_walk02', 'Tester_walk01', 'detail_file'], ['I_Have_a_Dream.txt'])
('Path_file/Tester_walk02', [], ['Tester_walk02_I_Have_a_Dream.txt'])
('Path_file/Tester_walk01', [], ['Tester_walk01_I_Have_a_Dream.txt'])
('Path_file/detail_file', [], ['Path_file_detail_file_I_Have_a_Dream.txt'])

Python os.walk() 笔记_第1张图片

你可能感兴趣的:(Python os.walk() 笔记)