看板 Python 關於我們 聯絡資訊
我有一行文字如下 module CPU_TOP (aaa) ( 我要用regular expression 找出CPU_TOP aaa兩個關鍵字 我表示如下 c1 = re.compile('^module\s(\S+)\s(\(\S+\))+\s\(') 結果找出來為[('CPU_TOP', '(aaa)')] 請問大大我應該如何改才能 ['CPU_TOP', 'aaa'] -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 61.57.149.215
Lucemia:re.compile('^module\s(\S+)\s\((\S+)\)+\s\(') 06/18 17:38
Lucemia:多包了一層 '(' 把那個拿掉就好 06/18 17:39