擅长:python、mysql、java
<p>显然,我没有足够高的声誉做任何事,除了张贴这个。联合国大学的答复并没有改变引文。我唯一发现的就是这个功能:</p>
<pre class="lang-py prettyprint-override"><code>import re
from htmlentitydefs import name2codepoint as n2cp
def decodeHtmlentities(string):
def substitute_entity(match):
ent = match.group(2)
if match.group(1) == "#":
return unichr(int(ent))
else:
cp = n2cp.get(ent)
if cp:
return unichr(cp)
else:
return match.group()
entity_re = re.compile("&(#?)(\d{1,5}|\w{1,8});")
return entity_re.subn(substitute_entity, string)[0]
</code></pre>
<p>我从这里得到的。</p>