用Python读取文件夹, 然后打开文件 下面读取到文件的每一个内容, 然后加上路径 import os path = r'../Downloads/text/content' for filename in os.listdir(path): print(os.path.join(path,filename))
python中可以用os.walk来遍历某个文件夹中所有文件夹和文件. 例1: import os filePath = 'C:/Users/admin/Desktop/img' for dirpath, dirnames, filenames in os.walk(filePath): print(dirpath, dirnames, filenames) 输出结果: 例2: import os filePath = 'C:\\Users\\admin\\Desktop\\img' for d