How to subtract two strings?

后端 未结 8 2045
执笔经年
执笔经年 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:16

    How about this?:

    def substract(a, b):                              
        return "".join(a.rsplit(b))
    

提交回复
热议问题