0

The output of my code is b'19.3882. How do I convert this to show only the integer output of 19.

I tried x=int(data) but that doesn't work. I also tried x=int(data.stdout) but to no avail.

Thanks.

Josh21
  • 506
  • 5
  • 15
PleaseHelp
  • 11
  • 2

1 Answers1

2

Try making it a float first? I assume it's python3.

>>> data = b'19.3882'
>>> int(data)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ValueError: invalid literal for int() with base 10: b'19.3882'
>>> float(data)
19.3882
>>> int(float(data))
19
The Pjot
  • 1,801
  • 1
  • 12
  • 20