python 遍历目录


import os
def print_tree(dir_path):
	for name in os.listdir(dir_path):
		full_path=os.path.join(dir_path,name)
		print(full_path)
		if os.path.isdir(full_path):
			print_tree(full_path)



print_tree("D:\\test\\")

你可能感兴趣的:(python 遍历目录)