Python or 關鍵字
定義和用法
or 關鍵字是邏輯運算符。
邏輯運算符用于組合條件語句。
如果其中一條語句返回 True,則返回值為 True,否則返回 False。
更多實例
實例
在 if 語句中使用 or 關鍵字:
if 5 > 3 or 5 > 10: print("At least one of the statements are True") else: print("None of the statements are True")
or 關鍵字是邏輯運算符。
邏輯運算符用于組合條件語句。
如果其中一條語句返回 True,則返回值為 True,否則返回 False。
在 if 語句中使用 or 關鍵字:
if 5 > 3 or 5 > 10: print("At least one of the statements are True") else: print("None of the statements are True")