#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""统计页面UI精简 - 使用正则替换"""
import re
with open('/www/wwwroot/zsglpt/templates/admin.html', 'r', encoding='utf-8') as f:
content = f.read()
# 使用正则找到统计标签页的内容
# 从
).*?(
\s*\n\s*)'
new_stats = '''
'''
# 使用正则替换
new_content, count = re.subn(pattern, new_stats, content, flags=re.DOTALL)
if count > 0:
print(f"OK - 成功替换 {count} 处")
with open('/www/wwwroot/zsglpt/templates/admin.html', 'w', encoding='utf-8') as f:
f.write(new_content)
else:
print("WARNING - 未找到匹配内容")
# 检查文件中是否有tab-stats
if 'id="tab-stats"' in content:
print("文件中存在 tab-stats")
# 找到位置
import re
match = re.search(r']*>', content)
if match:
print(f"位置: {match.start()}")
print(f"周围内容: {content[match.start():match.start()+200]}")