Accent problem, running at Windows Prompt

Asked

Viewed 3,087 times

4

I am creating software in Python, I’m having trouble accentuating the strings.

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

But when I show it, the accents don’t go right.. I’ll leave one. print error for you to see... I have tried to put u before the file and even input to test and still the error persists.

I gave one sys.getdefaultencoding() in the file to know what format and is utf-8.

I’ve tried to put:

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

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

2 answers

2


Since Python 3 there is no need to prefix the string with the character u, whichever string is already created using Unicode.

You are specifying the encoding in the wrong way, the right is:

# -*- coding: utf-8 -*-

0

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

Unicode characters will only be displayed if the current source of console contain the character. Use a font Truetype, as Lucida Console.

  • Even with Lucida Console gave bro :( It’s hard this thing saw.. I guess I’ll have to remove the accents and remove the accents from the strings the user types

Browser other questions tagged

You are not signed in. Login or sign up in order to post.