You should check out our tutorial for format method
since you didnt specify any restrictions....regex would probably be the least amount of code
since you didnt specify any restrictions....regex would probably be the least amount of code
>>> import re >>> re.sub('[^0-9]', '', 'Hello123') '123' >>> re.sub('[^0-9]', '', '!@#$%^&Hello123sdggjfhd') '123'
Recommended Tutorials: