Skip to main content
Stack Overflow
  1. About
  2. For Teams

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

Required fields*

Convert XML/HTML Entities into Unicode String in Python [duplicate]

I'm doing some web scraping and sites frequently use HTML entities to represent non ascii characters. Does Python have a utility that takes a string with HTML entities and returns a unicode type?

For example:

I get back:

ǎ

which represents an "ǎ" with a tone mark. In binary, this is represented as the 16 bit 01ce. I want to convert the html entity into the value u'\u01ce'

Answer*

Draft saved
Draft discarded
Cancel
3
  • Absolutely. Why is not in stdlib? Commented Aug 13, 2012 at 11:21
  • Looking at its code, it doesn't seem to work with & and such, does it? Commented Jun 14, 2013 at 12:22
  • Just tested successfully for & Commented Sep 30, 2013 at 20:50

default

AltStyle によって変換されたページ (->オリジナル) /