我在这里有一段代码来提取div.statement.p.Text
a = """<div class="theorem" id="theorem-AA" acro="AA" titletext="Adjoint of an Adjoint"> <h5 class="theorem"> <span class="type">Theorem </span><span class="acro">AA</span><span class="titletext"> Adjoint of an Adjoint</span> </h5> <div class="statement"><p>Suppose that $A$ is a matrix. Then $\adjoint{\left(\adjoint{A}\right)}=A$.</p></div> <div class="proof"><a knowl="./knowls/proof.AA.knowl">Proof</a></div> </div><div class="context"><a href="http://linear.pugetsound.edu/html/section-MO.html#theorem-AA" class="context" title="Section MO">(in context)</a></div> """
from bs4 import BeautifulSoup as bs
soup = bs(repr(a),features = 'lxml')
statement = bs(repr(soup.find_all("div", {"class": "statement"})[0])).find('p').text
print(statement)
后来的yields 是
Suppose that $A$ is a matrix. Then $\x07djoint{\\left(\x07djoint{A}\right)}=A$.
我需要输出为:
Suppose that $A$ is a matrix. Then $\adjoint{\left(\adjoint{A}\right)}=A$.
我怎么能这样做呢?