1

How does one properly decode string values containing special currency characters?

Example:

฿ đ

I've been playing around with .encode() and .decode() methods, but with no success.

dannier
  • 65
  • 4
  • Python does not automatically recognize html escape sequences. You must use the `html` library to parse them. – Aaron Jun 21 '19 at 14:17
  • Possible duplicate of [How do I unescape HTML entities in a string in Python 3.1?](https://stackoverflow.com/questions/2360598/how-do-i-unescape-html-entities-in-a-string-in-python-3-1) – Josh Lee Jun 21 '19 at 17:43

1 Answers1

3

Use html.unescape (doc):

from html import unescape

print(unescape('฿ đ'))

Prints:

฿ đ
Aaron
  • 10,133
  • 1
  • 24
  • 40
Andrej Kesely
  • 168,389
  • 15
  • 48
  • 91