2012-11-12 49 views
2

Python中以下語法正確嗎?如果循環語法錯誤

(if 'SU' in line or 'AU' in line or 'VU' in line or 'rf' in line and line.find('/*') == -1) and (BUILDROOT in line): 
    lineMatch = False 
+0

的'if'語句不啓動循環。 – Matthias

+0

運行你的代碼的結果是什麼?你得到的例外應該告訴你它不正確。 – Ber

+1

你應該從'if'之前刪除'(''。 – Bakuriu

回答

7

試試這個:

if any(x in line for x in ('SU', 'AU', 'VU', 'rf')) and '/*' not in line and BUILDROOT in line: 
    lineMatch = False