Extract Number from String in Python July 3, 2022 by Tarik You can filter the string by digits using str.isdigit method, >>> int(filter(str.isdigit, str1)) 3158