Python: Check if a string is a valid float

isfloat() function

def isfloat(value):
  try:
    float(value)
    return True
  except ValueError:
    return False

Use:
if(isfloat(arduinoString)):
        data = float(arduinoString)
        dataArray.append(arduinoString)
        index=index+1

Comments

Popular posts from this blog

HackRF with srsLTE and openlte

UART communication using Interrupts and Standard Peripheral Library

Read Continuously from Serial Port in QT