python替换开头的连续字符 替换连续的几个字符

>>> a='0000234230000'
>>> ac=re.sub('^0+','',a)
>>> ac
'234230000'
>>> ac=re.sub('0+','',a)
>>> ac
'23423'
>>>

posted @ 2022-03-18 06:43  myrj  阅读(71)  评论(0编辑  收藏  举报