import os filepath = r'd:\aicoding\kaiyuan\v2\index.html' with open(filepath, 'r', encoding='utf-8') as f: content = f.read() new_head = """ Aegis-Graph | Atlanta College of Liberal Arts and Sciences (ACLAS) """ start_idx = content.find('') end_idx = content.find('') if start_idx != -1 and end_idx != -1: updated_content = content[:start_idx] + new_head + content[end_idx:] with open(filepath, 'w', encoding='utf-8', newline='\n') as f: f.write(updated_content) print("SUCCESS: index.html head section reconstructed.") else: print("Error: Tags not found.")