I'm using PYTHON3 my output is like this "200:Just be close at Hand" I only need the 200 is there a way to remove the strings and symbol? Thanks
Asked
Active
Viewed 131 times
2 Answers
0
You can use regular expressions to remove anything that's not a number
>>> import re
>>> s = "200:Just be close at Hand"
>>> re.sub(r'[^\d]', "", s)
'200'
>>> s = "200:Just be close 33 at Hand 342"
>>> re.sub(r'[^\d]', "", s)
'20033342'

C. Ramseyer
- 2,322
- 2
- 18
- 22