Answers for "how to only get number from string in python"

1

python get int from string

>>> import re
>>> string1 = "498results should get"
>>> int(re.search(r'd+', string1).group())
498
Posted by: Guest on April-07-2020
0

how to get a number from a string in python

string = "I am 14 years old"
for i in string.split():
  if i.isdigit():
    print(i)
print()
Posted by: Guest on February-11-2021

Code answers related to "how to only get number from string in python"

Python Answers by Framework

Browse Popular Code Answers by Language