Weird function return value?

前端 未结 3 1061
南旧
南旧 2020-12-12 07:47

I am trying to remove everything between curly braces in a string, and trying to do that recursivesly. And I am returning x here when the recursion is over, but

3条回答
  •  北荒
    北荒 (楼主)
    2020-12-12 08:24

    Note that it is easier to use regular expressions:

    import re
    strs = "i am a string but i've some {text in brackets} braces, and here are some more {i am the second one} braces"
    strs = re.sub(r'{.*?}', '', strs)
    

提交回复
热议问题