2017-02-24 33 views

回答

3

,你可以嘗試通過'|'字符 分割字符串轉義括號什麼

Str = " a | (b | c) | d " 
a=re.split(r'\|\s*(?![^()]*\))',Str) 
print(a) 
[' a ', '(b | c) ', 'd '] 
+0

如何處理嵌套括號? – deathstroke05

相關問題