程序运行截图如下:
源码如下:
import os
def Traverse(dir):
list=[]
for dirpath,dirnamesList,filenamesList in os.walk(dir):
for filename in filenamesList:
list.append(dirpath+"\\"+filename)
for dirname in dirnamesList:
list.append(dirpath+"\\"+dirname+"\\")
pass
return list;
pass
if __name__=='__main__':
print(Traverse("D:\\MyTemplate"))
其他语言遍历文件夹:
Qt遍历文件夹:
https://blog.csdn.net/qq78442761/article/details/79796962
Java遍历文件夹:
https://blog.csdn.net/qq78442761/article/details/79418136