File size: 430 Bytes
ece3e8e
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
import re

with open('main.py', 'r', encoding='utf-8') as f:
    content = f.read()

with open('top5_v3.html', 'r', encoding='utf-8') as f:
    new_html = f.read()

pattern = re.compile(r'    return f\"\"\"<!DOCTYPE html>.*?</html>\"\"\"', re.DOTALL)
new_content = pattern.sub('    return f\"\"\"' + new_html + '\"\"\"', content)

with open('main.py', 'w', encoding='utf-8') as f:
    f.write(new_content)
    
print("Replaced!")