import re
def main(text: str) -> dict:
pattern = r'\|.*\|\n\|.*\|\n(\|.*\|\n)*'
matches = re.findall(pattern, text)
if matches:
table = matches[0].strip()
rows = [row.strip() for row in table.split('\n')]
headers = [h.strip() for h in rows[0].split('|')[1:-1]]
data = []
for row in rows[2:]:
cells = [c.strip() for c in row.split('|')[1:-1]]
data.append(dict(zip(headers, cells)))
return {'result': data}
return {'result': []}
暂无评论