The easiest way is with a regexp
import re
a="lkdfhisoe78347834 (())&/&745 "
result = re.sub('[^0-9]','', a)
print result
>>> '78347834745'
More Related Contents:
- Why is dictionary ordering non-deterministic?
- Import arbitrary python source file. (Python 3.3+)
- How to install pip for Python 3 on Mac OS X?
- Meaning of end=” in the statement print(“\t”,end=”)? [duplicate]
- ‘str’ object has no attribute ‘decode’ in Python3
- Can’t use chrome driver for Selenium
- Printing subscript in python
- Why is this not returning the expected ascending sequence? [closed]
- How to remove [ ] and ” from Python output [duplicate]
- Regular expression to return text between parenthesis
- How to avoid floating point errors? [duplicate]
- Python 3 turn range to a list
- Importing from a relative path in Python
- How to install PyQt4 on Windows using pip?
- DLL load failed when importing PyQt5
- “GetPassWarning: Can not control echo on the terminal” when running from IDLE
- SyntaxError: unexpected EOF while parsing
- Using Python Requests: Sessions, Cookies, and POST
- AttributeError: module ‘sipbuild.api’ has no attribute ‘prepare_metadata_for_build_wheel’ for PyQt5 5.15.0
- How can I use functools.singledispatch with instance methods?
- OpenSSL errors in python requests
- What is the problem with reduce()?
- How to use IFileOperation from ctypes
- How to test Python 3.4 asyncio code?
- How to run different python versions in cmd [duplicate]
- Discord.py error: TypeError: __new__() got an unexpected keyword argument ‘deny_new’
- How to strip all whitespace from string
- How to enable Pan and Zoom in a QGraphicsView
- How do I return dictionary keys as a list in Python?
- Python dictionary replace values