我用判斷回傳的instance去判斷re它有沒有match
沒有match的話 便執行下面的else
但是像下面例子會出現runtime error
說沒有test.group(0) 可是感覺這行應該不會執行到
應該是我觀念哪裡錯了 請問有人可以指導一下嗎 謝謝
Example:
import re
test=re.search('abc','def')
if test!=None:
print test.group(0)
else:
print 'no match'
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 140.123.216.148
→
11/22 23:06, , 1F
11/22 23:06, 1F
→
11/22 23:15, , 2F
11/22 23:15, 2F
→
11/22 23:19, , 3F
11/22 23:19, 3F