Python and encoding, again -
i have next code snippet in python (2.7.8) on windows:
text1 = 'áéíóú' text2 = text1.encode("utf-8")
and have next error exception:
unicodedecodeerror: 'ascii' codec can't decode byte 0xa0 in position 0: ordinal not in range(128)
any ideas?
you forgot specify dealing unicode string:
text1 = u'áéíóú' #prefix string "u" text2 = text1.encode("utf-8")
in python 3 behavior has changed, , string unicode, don't need specify it.
Comments
Post a Comment