python input UnicodeDecodeError:

Posted by The man on the Clapham omnibus on Stack Overflow See other posts from Stack Overflow or by The man on the Clapham omnibus
Published on 2012-07-08T21:12:45Z Indexed on 2012/07/08 21:15 UTC
Read the original article Hit count: 217

Filed under:
|
|

python 3.x

>>> a = input()
hope
>>> a
'hope'
>>> b = input()
håpe
>>> b
'håpe'
>>> c = input()

start typing hå... delete using backspace... and change to hope

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
UnicodeDecodeError: 'utf8' codec can't decode byte 0xc3 in position 1: invalid continuation byte
>>> 

The situation is not terrible, I am working around it, but find it strange that when deleting, the bytes get messed up. Has anyone else experienced this?

the terminal history shows that I thought that I entered h?ope

any ideas?

in the script that is using this, I do import readline to give command line history.

© Stack Overflow or respective owner

Related posts about python

Related posts about unicode