Skip to main content
Stack Overflow
  1. About
  2. For Teams

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

Required fields*

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*

Draft saved
Draft discarded
Cancel
13
  • yeah try that also , it work if we just print u"pokémon" but not "Pokémon GO Việt Nam" Commented Aug 31, 2016 at 21:37
  • @BrendaMartinez: what encoding is your editor using? Commented Aug 31, 2016 at 21:38
  • @BrendaMartinez make sure that both your IDE encoding as well as the project encoding are set to 'utf-8' Commented Aug 31, 2016 at 21:39
  • Utf-8 , notepad++ Commented Aug 31, 2016 at 21:39
  • @BrendaMartinez well notepad++ is another problem :) use a proper IDE such as PyCharm: you'll get all the benefits of IDE such as debugging and inspection capabilities as well as many other goodies. Commented Aug 31, 2016 at 21:41

lang-py

AltStyle によって変換されたページ (->オリジナル) /