Posts by Loip • 53 points
5 posts
-
0
votes2
answers954
viewsA: Read a txt avoiding problems with python accents
I was able to find the functional solution and in this case it would be to import IO and edit the open command line: import io f= io.open("olamundo.txt", "r", encoding="utf8") For those who want to…
-
1
votes2
answers172
viewsA: I would like to know how to write >>> print("Size = %4.2f cm" % Size) and what does %4.2f mean
Assuming you have the following code: Tamanho = 8.4726 print("Tamanho = %4.2f cm" % Tamanho) Then the return of the print using the variable Size of value 8.4726 would be: Size = 8.47 cm…
-
1
votes3
answers132
viewsA: Merge 2 Programs - Python (3)
My suggestion would be to first divide your programs into two functions: def reaispdolar () : Reais = float (input("Quantos reais? R$: ")) Cotação = float (input("Cotação de hoje é? ")) conversão =…
-
0
votes2
answers954
viewsQ: Read a txt avoiding problems with python accents
I’m trying to read a txt file but using the function below to display colors in the terminal and whenever the file has accents it returns me all messed up. COLORS = {\ "black":"\u001b[30;1m",…
-
2
votes2
answers215
viewsQ: How to access the lines of a file read by readlines()?
I’m trying to use the readlines, but it makes a mistake that I don’t understand the reason, see: arquivo = open("cadastros.txt", "r") loginarquivo = arquivo.readlines()[0] senhaarquivo =…