Reputation: 10697
In python, when I import sys
and type:
>>> sys.getdefaultencoding()
>>> 'ascii'
why is this string automatically encoded as UTF-8?
>>> a = 'ö'
>>> a
>>> '\xc3\xb6'
Upvotes: 0
Views: 177
Reputation: 240729
Because the input you provided to python was
a = ' ö '
\x61\x20\x3d\x20\x27\xc3\xb6\x27
You told a
to contain the byte sequence "\xc3\xb6"
by putting those two bytes between the quotes in your console input, and so it does.
Upvotes: 1