Python工作笔记-使用Py遍历文件夹及其子文件夹内容

程序运行截图如下:

源码如下:

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

©️2020 CSDN 皮肤主题: 数字20 设计师:CSDN官方博客 返回首页