遍历文件

import os
def func(filepath, n):
file = os.listdir(filepath)
for f in file:
file_p = os.path.join(filepath, f)
if os.path.isdir(file_p):
print("\t"* n, f , ":")
func(file_p, n+1 )
else:
print("\t"* n ,f)
pass
func("g:/salar", 0 )
posted @ 2019-11-25 18:29  冰灬荷  阅读(109)  评论(0编辑  收藏  举报