[root@web1 test]# cat walk.py #!/usr/bin/python # -*- coding: UTF-8 -*- import os for root, dirs, files in os.walk("/tmp", topdown=False): for name in files: print("文件") print(os.path.join(root,name)) for name in dirs: print("目录&q
用Python读取文件夹, 然后打开文件 下面读取到文件的每一个内容, 然后加上路径 import os path = r'../Downloads/text/content' for filename in os.listdir(path): print(os.path.join(path,filename))