How to subtract two strings?

后端 未结 8 2152
执笔经年
执笔经年 2020-12-30 00:53

I have a long string, which is basically a list like str=\"lamp, bag, mirror,\" (and other items)

I was wondering if I can add or subtract some items, i

8条回答
  •  自闭症患者
    2020-12-30 01:06

    you should convert your string to a list of string then do what you want. look

    my_list="lamp, bag, mirror".split(',')
    my_list.remove('bag')
    my_str = ",".join(my_list)
    

提交回复
热议问题