How can we strip punctuation at the start of a string using Python?

前端 未结 7 681
悲哀的现实
悲哀的现实 2021-01-14 11:43

I want to strip all kinds of punctuation at the start of the string using Python. My list contains strings and some of them starting with some kind of punct

7条回答
  •  天涯浪人
    2021-01-14 12:03

    If you want to remove it only from the begining, try this:

        import re
        s='"gets'
        re.sub(r'("|,,)(.*)',r'\2',s)
    

提交回复
热议问题