22 lines
993 B
Python
22 lines
993 B
Python
# markdown文件路径
|
||
import os
|
||
|
||
md_path = r'D:\dsWork\dsProject\dsLightRag\static\YunXiao\WangYouYiLiDingLv'
|
||
# 读取此目录下所有markdown文件,以文本方式读取即可
|
||
for file_name in os.listdir(md_path):
|
||
# 如果扩展名是 .md 的有用
|
||
if file_name.endswith('.md'):
|
||
print("==========================================================")
|
||
# 例:中等_1.md 输出 中等难度 第1题
|
||
print(file_name.split('_')[0] + "难度 第" + file_name.split('_')[1].split('.')[0] + "题")
|
||
# 读取文件内容
|
||
with open(os.path.join(md_path, file_name), 'r', encoding='utf-8') as f:
|
||
content = f.read()
|
||
content = content.replace('\>', '')
|
||
content = content.replace('>', '')
|
||
content = content.replace('\\', '')
|
||
if content and len(content.strip()) > 0:
|
||
print(content)
|
||
|
||
print("==========================================================")
|