How do I parse a string to a float or int?
Asked 07 September, 2021
Viewed 1.5K times
  • 57
Votes

In Python, how can I parse a numeric string like "545.2222" to its corresponding float value, 545.2222? Or parse the string "31" to an integer, 31?

I just want to know how to parse a float str to a float, and (separately) an int str to an int.

29 Answer