How to strip all non-numeric characters from string in Python

1 Answer

0 votes
s = '2a1-0/R@a9f#4K$$cC3K^htPam8vlQWhJ'

digits_filter = filter(str.isdigit, s)

s = "".join(digits_filter)

print(s);



'''
run:

2109438

'''

 



answered Jun 15, 2020 by avibootz

Related questions

2 answers 158 views
2 answers 150 views
2 answers 212 views
1 answer 223 views
1 answer 148 views
1 answer 202 views
...