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 149 views
2 answers 135 views
2 answers 198 views
1 answer 207 views
1 answer 132 views
1 answer 187 views
...