我有一個字符串,它看起來像這樣:有條件將字符串分割在Python
Increase (decrease) 1,334 ( 2,921) 2,797
我想拆分字符串看起來像這樣:
['Increase (decrease)', '1,334', '(2,921)', '2,797']
我已經試過:
item=re.split(r'\s{3,}', strg)
但顯然這產生了:
['Increase (decrease)', '1,334', '(', '2,921)', '2,797']
任何幫助將不勝感激。
嘗試'R '\ S {4}''? –
但是你爲什麼要這樣分裂?什麼是規則?例如'abc(123)(a a)',我不知道結果應該是什麼。只要解釋規則 –