Removing all non-numeric characters from string in Python

后端 未结 7 1093
遥遥无期
遥遥无期 2020-11-29 17:42

How do we remove all non-numeric characters from a string in Python?

7条回答
  •  天涯浪人
    2020-11-29 18:01

    >>> import re
    >>> re.sub("[^0-9]", "", "sdkjh987978asd098as0980a98sd")
    '987978098098098'
    

提交回复
热议问题