讲解Python中的标识运算符


Posted in Python onMay 14, 2015

 下表列出了所有Python语言支持的标识运算符。

讲解Python中的标识运算符

示例:

试试下面的例子就明白了所有Python编程语言提供的标识运算符:

#!/usr/bin/python

a = 20
b = 20

if ( a is b ):
  print "Line 1 - a and b have same identity"
else:
  print "Line 1 - a and b do not have same identity"

if ( id(a) == id(b) ):
  print "Line 2 - a and b have same identity"
else:
  print "Line 2 - a and b do not have same identity"

b = 30
if ( a is b ):
  print "Line 3 - a and b have same identity"
else:
  print "Line 3 - a and b do not have same identity"

if ( a is not b ):
  print "Line 4 - a and b do not have same identity"
else:
  print "Line 4 - a and b have same identity"

当执行上面的程序它会产生以下结果:

Line 1 - a and b have same identity
Line 2 - a and b have same identity
Line 3 - a and b do not have same identity
Line 4 - a and b do not have same identity

Python 相关文章推荐
python实现多线程暴力破解登陆路由器功能代码分享
Jan 04 Python
Python 创建子进程模块subprocess详解
Apr 08 Python
Python3遍历目录树实现方法
May 22 Python
python生成IP段的方法
Jul 07 Python
对pandas中Series的map函数详解
Jul 25 Python
Python箱型图绘制与特征值获取过程解析
Oct 22 Python
DJANGO-URL反向解析REVERSE实例讲解
Oct 25 Python
Python实现线性插值和三次样条插值的示例代码
Nov 13 Python
新手入门学习python Numpy基础操作
Mar 02 Python
python实现大文本文件分割成多个小文件
Apr 20 Python
python实现黄金分割法的示例代码
Apr 28 Python
python cv2图像质量压缩的算法示例
Jun 04 Python
在Python中使用成员运算符的示例
May 13 #Python
总结Python中逻辑运算符的使用
May 13 #Python
解析Python中的二进制位运算符
May 13 #Python
整理Python中的赋值运算符
May 13 #Python
实例说明Python中比较运算符的使用
May 13 #Python
举例讲解Python中的算数运算符的用法
May 13 #Python
详细解析Python中的变量的数据类型
May 13 #Python
You might like
PHP 分页类(模仿google)-面试题目解答
2009/09/13 PHP
php 判断字符串中是否包含html标签
2014/02/17 PHP
PHP编程中的__clone()方法使用详解
2015/11/27 PHP
php阿拉伯数字转中文人民币大写
2015/12/21 PHP
对php 判断http还是https,以及获得当前url的方法详解
2019/01/15 PHP
IE与firefox之jquery用法区别
2008/10/03 Javascript
关于Mozilla浏览器不支持innerText的解决办法
2011/01/01 Javascript
分享XmlHttpRequest调用Webservice的一点心得
2012/07/20 Javascript
eclipse导入jquery包后报错的解决方法
2014/02/17 Javascript
jQuery()方法的第二个参数详解
2015/04/29 Javascript
简单的jQuery拖拽排序效果的实现(增强动态)
2017/02/09 Javascript
NodeJS创建最简单的HTTP服务器
2017/05/15 NodeJs
three.js中3D视野的缩放实现代码
2017/11/16 Javascript
Vue中使用create-keyframe-animation与动画钩子完成复杂动画
2019/04/09 Javascript
ES6 Symbol数据类型的应用实例分析
2019/06/26 Javascript
vue项目中常见问题及解决方案(推荐)
2019/10/21 Javascript
JavaScript实现飞舞的泡泡效果
2020/02/07 Javascript
微信公众号网页分享功能开发的示例代码
2020/05/27 Javascript
vuejs实现下拉框菜单选择
2020/10/23 Javascript
利用python生成一个导出数据库的bat脚本文件的方法
2016/12/30 Python
Python 备份程序代码实现
2017/03/06 Python
Python set常用操作函数集锦
2017/11/15 Python
对numpy中数组元素的统一赋值实例
2018/04/04 Python
详解用python写网络爬虫-爬取新浪微博评论
2019/05/10 Python
tesserocr与pytesseract模块的使用方法解析
2019/08/30 Python
Python图像处理库PIL的ImageDraw模块介绍详解
2020/02/26 Python
解析python 中/ 和 % 和 //(地板除)
2020/06/28 Python
python写文件时覆盖原来的实例方法
2020/07/22 Python
Python 忽略文件名编码的方法
2020/08/01 Python
如何使用scrapy中的ItemLoader提取数据
2020/09/30 Python
python字典按照value排序方法
2020/12/28 Python
美国高端医师级美容产品电商:BeautifiedYou.com
2017/04/17 全球购物
EJB实例的生命周期
2016/10/28 面试题
年会主持词结束语
2014/03/27 职场文书
小学数学教学经验交流材料
2014/05/22 职场文书
信息管理专业自荐书
2014/06/05 职场文书