Python中的多重拆分

Jos*_*h K 2 python string split

我如何用两个相反的值分割字符串?例如(,它)是"deliminators",我有以下字符串:

Wouldn't it be (most) beneficial to have (at least) some idea?
Run Code Online (Sandbox Code Playgroud)

我需要以下输出(作为数组)

["Wouldn't it be ", "most", " beneficial to have ", "at least", " some idea?"]
Run Code Online (Sandbox Code Playgroud)

qua*_*oup 13

re.split()

s = "Wouldn't it be (most) beneficial to have (at least) some idea?"
l = re.split('[()]', s);
Run Code Online (Sandbox Code Playgroud)