How to encode and decode from spanish in python
encoding, python, python-2.7, unicode
Solution
Add `u` before the `"`
>>> _string = u"años luz detrás"
>>> print _string.encode("utf-8")
años luz detrás
This would do.
Problem
I have the following code written in python 2.7 ``` # -*- coding: utf-8 -*- import sys _string = "años luz detrás" print _string.encode("utf-8") ``` this throws the following error: ``` print _string.encode("utf-8") UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 1: ordinal not in range(128) ``` Any help appreciated, thanks in advance