I have an entire string in python. I want to isolate part of that which is a number with a decimal and convert into an int. I've searched and tried lots of things including an array but no dice.
#msg.payload is a string of 1:3.45
s = msg.payload
print(msg.payload)
if (s[0] == "1"):
print("Distance from Anchor 1 received")
d1 = arr.array((s[2], ".", s[4], s[5]))
d1converted = int(d1)
print(d1)
I want to isolate '3.45' from the string '1:3.45' and then convert the '3.45' to an int. I know once you have '3.45' as a string you can simply do int(3.45) to convert it. However, I'm struggling isolating that part of the string with the decimal in the first part. Any help is greatly appreciated!