<p>另一个解决方案:</p>
<pre><code>import re
from bs4 import BeautifulSoup
txt = '''<p id="p-9">
<span class="inline-l2-heading">H5N1 virus pathogenic phenotypes among
inbred mouse strains.
</span>
We experimentally inoculated 21 mouse strains with the highly
pathogenic H5N1 influenza A virus A/Hong Kong/213/03 (HK213)
and monitored the animals for 30 days thereafter for signs of
morbidity and mortality. The 50% mouse lethal dose (MLD<sub>50</sub>)
values varied from 40 50% egg infective doses (EID<sub>50</sub>)
for the influenza virus-susceptible strain DBA/2<sub>S</sub>
(susceptibility indicated by “S”) to more than 10<sup>6</sup>
EID<sub>50</sub> for the influenza virus-resistant strains
BALB/c<sub>R</sub> and BALB/cBy<sub>R</sub>
(resistance indicated by “R”) (<a class="xref-fig" href="#F1" id="xref-fig-1-
1">Fig. 1</a>).
</p>'''
soup = BeautifulSoup(txt, 'html.parser')
paragraph = soup.select_one('p')
# add space at the end of each span:
for span in paragraph.select('span'):
span.append(BeautifulSoup('&nbsp;', 'html.parser'))
# post-process the text:
print(re.sub(r'\s{2,}', ' ', paragraph.text).strip())
</code></pre>
<p>印刷品:</p>
<pre><code>H5N1 virus pathogenic phenotypes among inbred mouse strains. We experimentally inoculated 21 mouse strains with the highly pathogenic H5N1 influenza A virus A/Hong Kong/213/03 (HK213) and monitored the animals for 30 days thereafter for signs of morbidity and mortality. The 50% mouse lethal dose (MLD50) values varied from 40 50% egg infective doses (EID50) for the influenza virus-susceptible strain DBA/2S (susceptibility indicated by “S”) to more than 106 EID50 for the influenza virus-resistant strains BALB/cR and BALB/cByR (resistance indicated by “R”) (Fig. 1).
</code></pre>