Python operator.not_()函数与示例
operator.not_()函數 (operator.not_() Function)
operator.not_() function is a library function of operator module, it is used to perform "NOT operation" on a given value and returns True if the given value is zero or any falsy value, False, otherwise.
operator.not_()函數是運營商模塊的庫函數,它被用于如果給定的值是零或任何falsy值, 假上的給定值并返回true執行“NOT操作”,否則。
Module:
模塊:
import operatorSyntax:
句法:
operator.not_(x)Parameter(s):
參數:
x – value on which NOT operation to be performed.
x-要對其執行NOT操作的值。
Return value:
返回值:
The return type of this method is bool, it returns True if x is zero or any falsy value, False, otherwise.
此方法的返回類型為布爾 ,如果x是零或任何falsy值, 假返回true,否則。
Example:
例:
# Python operator.not_() Function Exampleimport operatorprint("operator.not_(True):", operator.not_(True)) print("operator.not_(False):", operator.not_(False)) print()x = 1 print("x:", x) print("operator.not_(x):", operator.not_(x)) print()x = 10 print("x:", x) print("operator.not_(x):", operator.not_(x)) print()x = -10 print("x:", x) print("operator.not_(x):", operator.not_(x)) print()x = 0 print("x:", x) print("operator.not_(x):", operator.not_(x)) print()x = "Hello" print("x:", x) print("operator.not_(x):", operator.not_(x)) print()x = "" print("x:", x) print("operator.not_(x):", operator.not_(x)) print()Output:
輸出:
operator.not_(True): False operator.not_(False): Truex: 1 operator.not_(x): Falsex: 10 operator.not_(x): Falsex: -10 operator.not_(x): Falsex: 0 operator.not_(x): Truex: Hello operator.not_(x): Falsex: operator.not_(x): True翻譯自: https://www.includehelp.com/python/operator-not_-function-with-examples.aspx
創作挑戰賽新人創作獎勵來咯,堅持創作打卡瓜分現金大獎總結
以上是生活随笔為你收集整理的Python operator.not_()函数与示例的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: drawer的用法_MMDrawerCo
- 下一篇: 北京soul_Soul高智商情侣,机器人