发布时间:2019-07-19 09:50:45编辑:auto阅读(1758)
import os
def DeepthSearch(path):
stack1 = []
OrdinaryFiles = []
stack1.append(path)
num = 0
while len(stack1) != 0:
one = stack1.pop()
filelist = os.listdir(one)
for item in filelist:
abspath = os.path.join(one, item)
if os.path.isdir(abspath):
stack1.append(abspath)
else:
#print(abspath)
OrdinaryFiles.append(abspath)
num += 1
print("the %d time"%num, stack1)
return OrdinaryFiles
pt = DeepthSearch(r"D:\dir")
for item in pt:
print(item)
上一篇: C++程序员Python notes
下一篇: python生成随机数
47483
45786
36784
34310
28955
25589
24436
19606
19096
17626
5458°
6041°
5557°
5632°
6558°
5370°
5370°
5877°
5850°
7163°