In Python, how can I parse a numeric string like \"545.2222\" to its corresponding float value, 545.2222? Or parse the string \"31\" t
\"545.2222\"
545.2222
\"31\"
def get_int_or_float(v): number_as_float = float(v) number_as_int = int(number_as_float) return number_as_int if number_as_float == number_as_int else number_as_float