import os import re from bs4 import BeautifulSoup from funcs import read_from_json, save_to_file_by_address base_address = os.getcwd() html_address = base_address + "/main_qa_data/data/sections_set_02.json" data = read_from_json(html_address) html = '' start_part = "
" end_part = "" for i, line in enumerate(data): id = line["id"] content = line["content"] result = line["result"] sentences = result.split("*") #start_part = "" #end_part = "" html_id = "" + content + "
" html_sentences = '' for item in sentences: if not item: continue html_sentences += "" + item + "
" html += html_id + html_content + html_sentences + "