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 Example
import operator
# integers
x = 10
y = 20
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()
# 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):  False
x: Apple , y: Banana
operator.ne(x,y):  True
operator.ne(y,x):  True
operator.ne(x,x):  False
operator.ne(y,y):  False
type((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 20
RUN 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()函数与示例相关推荐

  1. Python operator.not_()函数与示例

    operator.not_()函数 (operator.not_() Function) operator.not_() function is a library function of opera ...

  2. Python operator.truth()函数与示例

    operator.truth()函数 (operator.truth() Function) operator.truth() function is a library function of op ...

  3. Python operator.le()函数与示例

    operator.le()函数 (operator.le() Function) operator.le() function is a library function of operator mo ...

  4. Python operator.lt()函数与示例

    operator.lt()函数 (operator.lt() Function) operator.lt() function is a library function of operator mo ...

  5. python operator __gt___Python operator.gt方法代码示例

    本文整理汇总了Python中operator.gt方法的典型用法代码示例.如果您正苦于以下问题:Python operator.gt方法的具体用法?Python operator.gt怎么用?Pyth ...

  6. C++编程进阶3(如何写出正确的operator=、operator运算符的返回值以及是否应该是成员函数的讨论)

    八.如何写出一个安全的operator= 首先,operator=的返回值通常是一个类的引用,这一点需要和C++标准库的容器类的operator=保持一致 其次,如果一个类中含有指针成员,那么要防止自 ...

  7. python中使用operator.itemgetter()函数实现excel的自定义排序功能

    使用工具为vscode,python预处理csv数据,先将其转化为list,如图 这里是一个[ [x1,x2,x3...],[y1,y2,y3...],... ]格式的嵌套数组,那么如何将其先按第一列 ...

  8. 课时 24:Kubernetes API 编程利器:Operator 和 Operator Framework(夙兴)

    本节课程主要分享以下三方面的内容: operator 概述 operator framework 实战 工作流程 operator 概述 基本概念 首先介绍一下本节所涉及到的基本概念. CRD (Cu ...

  9. C++ new/new operator、operator new、placement new初识

    简要释义 1.operator new是内存分配函数(同malloc),C++在全局作用域(global scope)内提供了3份默认的operator new实现,并且用户可以重载operator ...

最新文章

  1. MongoDB 全文检索
  2. networkx中求解平均度_机器学习之统计学二(分位数、平均数)
  3. Linux系统抓包回放,Linux下24小时持续网络抓包(TCPDUMP)
  4. 【效率】再见 Typora,这款 Markdown 编辑器开源又免费!
  5. 字符串之单词原地逆转
  6. 第五人格pcmac_第五人格:未上线,勘探员已经让庄园内的CP乱了分寸,祭司最绝...
  7. 继上一篇博客--javaweb通过接口来实现多个文件压缩和下载(包括单文件下载,多文件批量下载)
  8. Python使用tensorflow中梯度下降算法求解变量最优值
  9. sublime配置python-rpel_SublimeREPL配置Python3开发
  10. linux 临时去掉cp别名_命令别名:保护和服务
  11. vim python一键执行、高亮等一键安装
  12. Java基础-标识符
  13. java从数据库映射实体类的代码
  14. vscode无法更改文件夹名称
  15. CF 592D(Super M-虚树直径)
  16. CentOS官网下载对应版本
  17. phpcms v9 二次开发 前台上传图片
  18. spring自动填充
  19. UR机器人通信接口总结
  20. 2021年危险化学品生产单位安全生产管理人员考试题及危险化学品生产单位安全生产管理人员最新解析

热门文章

  1. python能不能用c打开文件_C/C++/Python等 使用二进制模式打开文件与不使用二进制模式的区别...
  2. jquery 给iframe里的元素添加事件
  3. 基于面向对象的图片轮播(js原生代码)
  4. HTML 部分常用属性、组成属性|...超链接、路径、锚点、列表、滚动、URL编码、表格、表单、GET和POST
  5. web前端常用知识点
  6. php开发微信图灵机器人
  7. CPU-内存-IO-网络调优
  8. mybatis 使用merge into
  9. HTML基础入门学习准备篇
  10. 004-JQuery属性