对python的手册真的很无语

ImN1 ImN1 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区
python3.3手册HTMLParser一节居然没写支持 unescape(),只列在SAX一节
还是google到别人这样用才晓得
灰常有用的函数啊


>>> import html.parser
>>> h = html.parser.HTMLParser()
>>> s = h.unescape('© 2010')
>>> s
u'\xa9 2010'
>>> print s
© 2010
>>> s = h.unescape('© 2010')
>>> s
u'\xa9 2010'

>>> '袈'.encode("unicode-escape")
b'\\u8888'
>>> chr(int('8888', 16))
'袈'

>>> h.unescape('♥')
'♥'
>>> h.unescape('♥')
'♥'
>>> h.unescape('♥')
'♥'
>>> '♥'.encode("unicode-escape")
b'\\u2665'
>>> chr(int('2665', 16))
'♥'

>>> import html.entities as h
>>> h.name2codepoint['hearts']
9829
...全文

相关推荐

评论 12
收藏 已收藏
分享
返回顶部
ImN1
脚本语言 37,737 成员 34,208 内容