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
4

2 回答 2

7

试试这个:

if any(x in line for x in ('SU', 'AU', 'VU', 'rf')) and '/*' not in line and BUILDROOT in line:
    lineMatch = False
于 2012-11-12T08:48:20.727 回答
5

不,if不应该在括号内。

于 2012-11-12T08:44:10.793 回答