Decimals reading Python

Hello,

i'm new in python. Consider that i have this function that read me some data from a serial :

def GetData():
  line = open(serialx).read()
  hash = line.find("#")
  when = line[:hash]
  count = line[hash+1:-1]
  # print when, count, line
  return (float(when), int(count))

it gives me the result with tre digits like 301 300 301 etc.. how i can have more decimals (and precision reading) to achieve a result of ex 3000001 eventually using another counter too like +001 -001?

Thank you

Regards

Hi Board27,

This is the information I have parsed so far.
return (float(when), int(count)) will give you a tuple comprised of a float and an int, but you say -- "it gives me the result with tre digits like 301 300 301 etc ..."
I do not understand, there is no tuple but a number. You say -- "how i can have more decimals (and precision reading)", however there are no decimals in your post.
Somewhat you want to make the number three hundred and one (301) into the number three millions and one (3000001)

A decimal would be 0.301 and if you want to add seven digits of precision it will become 0.3010000 , never 0.3000001

Please, could you clarify a bit more your request? Perhaps, could you consider posting the content of the file serialx ?

1 Like

Thanks, floating points numbers did it.

Thanks

regards