Ways to slice a string?

后端 未结 6 653
渐次进展
渐次进展 2020-12-01 21:16

I have a string, example:

s = \"this is a string, a\"

Where a \',\' (comma) will always be the 3rd to the last character, aka

6条回答
  •  忘掉有多难
    2020-12-01 22:00

    For deleting every ',' character in the text, you can try

    s = s.split(',')
    >> ["this is a string", " a"]
    s = "".join(s)
    >> "this is a string a"
    

    Or in one line:

    s0 = "".join(s.split(','))
    

提交回复
热议问题