0

I use Python 3.4 for Windows. I've found this solution in SO:

import html
print(html.unescape('&#pound;682'))

Yet it does not work, neither it works with numeric encoded value: £

import html
print(html.unescape('£682'))

The error is:

UnicodeEncodeError: 'charmap' codec can't encode character '\xa3' in position 0: character maps to <undefined>

Update

Thanks to Kevin I've found this useful:

print(html.unescape('&#163;682m'.encode(sys.stdout.encoding, errors='replace'))) 

yet another error:

TypeError: 'str' does not support the buffer interface What else can I try to decode it?

Community
  • 1
  • 1
Igor Savinkin
  • 5,669
  • 8
  • 37
  • 69

0 Answers0