# encoding: utf-8
import os
path = "C:\Users\Administrator\Desktop\data"
for filename in os.listdir(path):
print("文件名:"+filename)
print(filename+"内容:" )
file = open(path+"\"+filename,'r')
content = file.readlines()
print(content)
print("结束!")
文件列表:
代码结果: