Removing all digits from a string on python

后端 未结 2 1666
不知归路
不知归路 2020-12-22 06:29

So i need some help on removing the digits from this string

import re

g=\"C0N4rtist\"

re.sub(r\'\\W\',\'\',g)\'

2条回答
  •  清酒与你
    2020-12-22 06:57

    There is no need to use regex for this. you can use isdigit() function

       def removeDigitsFromStr(_str):
            result = ''.join(i for i in _str if not i.isdigit())
            return result
    

提交回复
热议问题