Files
ALL-teach_sys/frontend_食品/remove_bold_marks.py

74 lines
2.9 KiB
Python
Raw Normal View History

#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
删除食品修改版简历中的加粗符号
"""
import os
import re
# 定义需要处理的文件列表
files_to_process = [
"/Users/apple/Documents/cursor/教务系统/frontend_食品/网页未导入数据/食品产业/食品修改版简历/营养师.md",
"/Users/apple/Documents/cursor/教务系统/frontend_食品/网页未导入数据/食品产业/食品修改版简历/注册专员.md",
"/Users/apple/Documents/cursor/教务系统/frontend_食品/网页未导入数据/食品产业/食品修改版简历/健康管理师.md",
"/Users/apple/Documents/cursor/教务系统/frontend_食品/网页未导入数据/食品产业/食品修改版简历/食品产品经理.md",
"/Users/apple/Documents/cursor/教务系统/frontend_食品/网页未导入数据/食品产业/食品修改版简历/食品体系专员.md",
"/Users/apple/Documents/cursor/教务系统/frontend_食品/网页未导入数据/食品产业/食品修改版简历/食品生产主管.md",
"/Users/apple/Documents/cursor/教务系统/frontend_食品/网页未导入数据/食品产业/食品修改版简历/食品工艺工程师.md",
"/Users/apple/Documents/cursor/教务系统/frontend_食品/网页未导入数据/食品产业/食品修改版简历/供应商质量工程师.md"
]
def remove_bold_marks(file_path):
"""删除文件中的加粗符号"""
try:
# 读取文件内容
with open(file_path, 'r', encoding='utf-8') as f:
content = f.read()
# 查找所有加粗的文本
bold_pattern = re.compile(r'\*\*(.+?)\*\*')
matches = bold_pattern.findall(content)
if matches:
print(f"\n处理文件: {os.path.basename(file_path)}")
print(f"找到 {len(matches)} 处加粗文本:")
for match in matches:
print(f" - {match}")
# 删除加粗符号
content_modified = bold_pattern.sub(r'\1', content)
# 写回文件
with open(file_path, 'w', encoding='utf-8') as f:
f.write(content_modified)
print(f"✓ 已删除所有加粗符号")
return True
else:
print(f"\n文件 {os.path.basename(file_path)} 没有找到加粗文本")
return False
except Exception as e:
print(f"✗ 处理文件 {file_path} 时出错: {e}")
return False
def main():
"""主函数"""
print("=" * 50)
print("开始删除食品修改版简历中的加粗符号")
print("=" * 50)
success_count = 0
total_count = len(files_to_process)
for file_path in files_to_process:
if remove_bold_marks(file_path):
success_count += 1
print("\n" + "=" * 50)
print(f"处理完成: {success_count}/{total_count} 个文件成功处理")
print("=" * 50)
if __name__ == "__main__":
main()