Does word conversion with upper () string not work for certain letters?

Hi guys, I hope you can help me with this problem, I have a watch 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 turn "Ʊ" into "Ƒ" or "ó" into "Ɠ"

Any idea?

+5
source share
2 answers

Use a Unicode literal (a string literal with leading u ) to represent a unicode string:

 >>> frase = u'La canción de la piƱa' >>> print frase.upper() LA CANCIƓN DE LA PIƑA 

UPDATE

Adding the next line at the beginning of the file includes automatic literals in Unicode format. (In the interactive shell, statements will depend on import operators.)

 from __future__ import unicode_literals 

See __future__ definitions of future statements .

+6
source

Unicode Literal:

Try the following:

frase = u'La canción de la piña '

0
source

All Articles