Brenda Martinez Brenda Martinez - 3 months ago 12
Python Question

Unicode python Error

i'm trying to print : Pokémon GO Việt Nam

print u"Pokémon GO Việt Nam"


and i'm getting :

print u"PokÚmon GO Vi?t Nam"
SyntaxError: (unicode error) 'utf8' codec can't decode byte 0xe9 in position 0: unexpected end of data


i've tried :

.encode("utf-8")
.decode("utf-8")
.decode('latin-1').encode("utf-8")
unicode(str.decode("iso-8859-4"))


My python version is 2.7.9 , Notepad++ UTF-8 encoding .
with no luck , how can i print it ? and i'm encountering this kind of issues all the time , what's the proper way to debug and get the right encoding ?

Answer
#!/usr/bin/python
# -*- coding: utf-8 -*-

print "Pokémon GO Việt Nam"

You can find here more info

For PyCharm settings, go to the menu: PyCharm --> Preference then use the search to look up "encoding", you should reach the following screen:

enter image description here