Printing accented characters in Python 2.7

I am new to python. I am trying to print accented characters, for example:

# -*- coding: utf-8 -*- print 'éàÇÃãéèï' 

But when I execute this code, I get:

  >> ├®├á├ç├â├ú├®├¿├» 

I am using 64-bit versions of Windows 7 and Python 2.7.5, I have code in file.py and execute it with

 python file.py 
+6
source share
1 answer

As Wooble mentioned, if you change

 print 'éàÇÃãéèï' 

to

 print u'éàÇÃãéèï' 

It should work.

Here is a good introduction to unicode in python (both for 2.x and 3): Updated unicode manual

+3
source

Source: https://habr.com/ru/post/952508/


All Articles