Hello guys I hope you can help me with this problem, I've have hours trying to solve it
Using this code:
#!/usr/bin/python
# -*- encoding: utf-8 -*-
frase = 'La canción de la piña'
print frase.upper()
I just get "LA CANCIóN DE LA PIñA", the problem is that it does not make the "ñ" in to a "Ñ" or "ó" in "Ó"
Any idea ?
Use unicode literal (string literal with leading u
) to represent unicode string:
>>> frase = u'La canción de la piña'
>>> print frase.upper()
LA CANCIÓN DE LA PIÑA
UPDATE
Adding following line at the beginning of the file enables automatic unicode literals. (In interactive shell, statements follow the import statements will be affected.)
from __future__ import unicode_literals
See __future__
- future statement definitions.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With