어제 조건문을 작성하는 동안 이상한 선행 규칙으로 보았습니다. 내가 가진 성명은논리적 연산자가 파이썬에서 AND 및 OR로 바인딩됩니다.
if not condition_1 or not condition_2 and not condition_3:
내가 내 마음에
if True or True and False:
# Evaluates to true and enters conditional
(그리고 다른 언어 이전의 경험에서) 우선 순위를 가져야 and
조건이 문이 평가로 발견했다 - 그래서 문은해야
if (True or True) and (False):
동등하지만, 실제 사실 그것은
if (True) or (True and False):
내게 이상한 것 같습니까? 파이썬 위키에서
무엇이 문제입니까? –
['or'는'and'보다 우선 순위가 낮습니다.] (https://docs.python.org/2/reference/expressions.html#operator-precedence) –