改成批量读取文件夹里面的
时间: 2023-12-15 22:06:03 浏览: 55
批量修改文件夹
代码:
import os
folder_path = 'folder_path'
for filename in os.listdir(folder_path):
if filename.endswith('.txt'):
file_path = os.path.join(folder_path, filename)
with open(file_path, 'r') as file:
content = file.read()
# do something with the content of the file
阅读全文