日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程语言 > python >内容正文

python

operator.ne_Python operator.ne()函数与示例

發布時間:2023/12/1 python 30 豆豆
生活随笔 收集整理的這篇文章主要介紹了 operator.ne_Python operator.ne()函数与示例 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

operator.ne

operator.ne()函數 (operator.ne() Function)

operator.ne() function is a library function of operator module, it is used to perform "not equal to operation" on two values and returns True if the first value is not equal to the second value, False, otherwise.

operator.ne()函數是運營商模塊的庫函數,它被用于在兩個值并返回true執行“不等于操作”如果第一個值不等于所述第二值, 假 ,否則。

Module:

模塊:

import operator

Syntax:

句法:

operator.ne(x,y)

Parameter(s):

參數:

  • x,y – values to be compared.

    x,y –要比較的值。

Return value:

返回值:

The return type of this method is bool, it returns True if x is not equal to y, False, otherwise.

此方法的返回類型為bool ,如果x不等于y ,則返回True ,否則返回False 。

Example 1:

范例1:

# Python operator.ne() Function Exampleimport operator# integers x = 10 y = 20print("x:",x, ", y:",y) print("operator.ne(x,y): ", operator.ne(x,y)) print("operator.ne(y,x): ", operator.ne(y,x)) print("operator.ne(x,x): ", operator.ne(x,x)) print("operator.ne(y,y): ", operator.ne(y,y)) print()# strings x = "Apple" y = "Banana"print("x:",x, ", y:",y) print("operator.ne(x,y): ", operator.ne(x,y)) print("operator.ne(y,x): ", operator.ne(y,x)) print("operator.ne(x,x): ", operator.ne(x,x)) print("operator.ne(y,y): ", operator.ne(y,y)) print()# printing the return type of the function print("type((operator.ne(x,y)): ", type(operator.ne(x,y)))

Output:

輸出:

x: 10 , y: 20 operator.ne(x,y): True operator.ne(y,x): True operator.ne(x,x): False operator.ne(y,y): Falsex: Apple , y: Banana operator.ne(x,y): True operator.ne(y,x): True operator.ne(x,x): False operator.ne(y,y): Falsetype((operator.ne(x,y)): <class 'bool'>

Example 2:

范例2:

# Python operator.ne() Function Example import operator# input two numbers x = int(input("Enter first number : ")) y = int(input("Enter second number: "))# printing the values print("x:",x, ", y:",y)# comparing if operator.ne(x,y):print(x, "is not equal to", y) else:print(x, "is equal to", y)

Output:

輸出:

RUN 1: Enter first number : 10 Enter second number: 20 x: 10 , y: 20 10 is not equal to 20RUN 2: Enter first number : 10 Enter second number: 10 x: 10 , y: 10 10 is equal to 10

翻譯自: https://www.includehelp.com/python/operator-ne-function-with-examples.aspx

operator.ne

總結

以上是生活随笔為你收集整理的operator.ne_Python operator.ne()函数与示例的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。