This question has already been answered:

# coding: utf-8 print "Привет мир!" вывод: Привет РјРёСЂ! 

Reported as a duplicate by jfs , Timofei Bondarev , aleksandr barakin , Vladimir Glinskikh , Peter Olson on Aug 14 '15 at 2:52 .

A similar question was asked earlier and an answer has already been received. If the answers provided are not exhaustive, please ask a new question .

1 answer 1

Here is the actual cut from the article:

To tell Python that the script uses a non-ASCII encoding, you need to place a special type of comment at the beginning of the file containing the file encoding information. For the russian.py script created in Notepad, we specify the cp1251 encoding, after which the script will look like this:

 > # -*- coding: cp1251 -*- > > `print 'Привет мир!'` 

After that we can successfully execute the script in

Windows console window (just remember to set the current encoding with the command chcp 1251):

 > C:\>chcp 1251 Active code page: 1251 > > C:\>python russian.py Привет мир! 
  • one
    thanks for the help! - Denis Boiko
  • 2
    @DenisBoiko: coding: cp1251 + chcp 1251 is a bad decision. Leave coding: utf-8 as it is, do not call chcp 1251 , do not print the text as bytes, but use Unicode u"Привет мир!" instead (note the u'' prefix"). To print text with arbitrary Unicode characters, see, my answer is jfs