下表列出了所有Python语言支持的标识运算符。
示例:
试试下面的例子就明白了所有Python编程语言提供的标识运算符:
#!/usr/bin/pythona = 20b = 20if ( 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 = 30if ( 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 IDentityline 2 - a and b have same IDentityline 3 - a and b do not have same IDentityline 4 - a and b do not have same IDentity
以上是内存溢出为你收集整理的讲解Python中的标识运算符全部内容,希望文章能够帮你解决讲解Python中的标识运算符所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)