Python delete in a string

后端 未结 4 1644
长情又很酷
长情又很酷 2021-01-21 08:51

I have these 3 strings:

YELLOW,SMALL,STRETCH,ADULT,T21fdsfdsfs
YELLOW,SMALL,STRETCH,ADULT,Tdsfs
YELLOW,SMALL,STRETCH,ADULT,TD

4条回答
  •  离开以前
    2021-01-21 09:08

    You can't. Create a new string with the pieces you want to keep.

    ','.join(s.split(',')[:4])
    

提交回复
热议问题