파이썬 if 문 질문 드립니다..
조회수 886회
per1 = ".25"
per2 = ".75"
if row[23] == 'sale1' or row[23] == 'sale2':
if row[27].find(per1) == -1:
cursor.execute(sql)
else:
cursor.execute(sql)
또는
per2 = ".75"
if row[23] == 'sale1' or row[23] == 'sale2':
if row[27].find(per2) == -1:
cursor.execute(sql)
else:
cursor.execute(sql)
이렇게 하면 제대로 걸러지는데
per1 = ".25"
per2 = ".75"
if row[23] == 'sale1' or row[23] == 'sale2':
if row[27].find(per1) == -1 and row[27].find(per2) == -1:
cursor.execute(sql)
else:
cursor.execute(sql)
이런경우 전혀 걸러지지 않네요..
왜그런걸까요?
-
(•́ ✖ •̀)
알 수 없는 사용자
1 답변
-
per1 = ".25" per2 = ".75" if row[23] == 'sale1' or row[23] == 'sale2': if row[27].find(per1) == -1 or row[27].find(per2) == -1: cursor.execute(sql) else: cursor.execute(sql)
and를 or로 바꾸세요.
댓글 입력