Vote count:
0
In the project I am currently working on, I need to read data as float out of a text file, and add it with a
float(raw_input())
, but when I do something like
from sys import argv
script, filename = argv
target = open(filename) #say there is a value of 42 in this text file
indata = float(filename.read()) #reading it as float
input = float(raw_input('>' )) #saving a user input as float, say i enter in 0.5
result = indata + input #doing the math
as a result, i get 43, the rounded version, rather than the actual answer, 42.5. Can anyone help me? Thanks!
asked 1 min ago
Python: Doing math with floats- not working the way i wan't it
Aucun commentaire:
Enregistrer un commentaire