Problem with accents, running in Windows Prompt

3

I'm creating software in Python , I'm having problems with string accents.

The program is simple .. It asks questions to the user (name, version, description, etc.) and adds the answers of these questions in the middle of a text file .. In the end it displays the contents of the text file for the user to copy.

But when displaying, the accents do not look right. I'll leave a% of the error for you to see ... I've already tried to put u before the file and even the input for testing and still the error persists.

I gave print to the file to know which format and is sys.getdefaultencoding() .

I've tried to put:

  • utf-8
  • # -- coding: UTF-8 --
  • # -- coding: iso-8859-1 --
  • #-- coding: latin-1 --

ERROR http://www.imgfans.com.br/i777/SirGates/erro.png .

    
asked by anonymous 23.03.2015 / 15:01

2 answers

1
Since Python 3 there is no need to prefix the string with the u character, any string is already created using unicode .

You're specifying the encoding in the wrong way, the right one is:

# -*- coding: utf-8 -*-
    
23.03.2015 / 15:12
0

The problem is in the prompt of Windows. According to the extract this answer in SOEn:

Unicode characters will only be displayed if the current font of the console contains the character. Use a TrueType font, such as Lucida Console.

    
23.03.2015 / 15:42