Blogger Information
Blog 85
fans 0
comment 0
visits 72684
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
Python零基础入门-基础语法-运算符-身份运算符
Smile
Original
449 people have browsed it

  运算符

  描述

  实例

  is

  is 判断两个变量是不是引用自一个对象

  x is y, 如果引用的是同一个对象则返回 True,否则返回 False

  is not

  is not 判断两个变量是不是引用自不同对象

  x is not y ,如果引用的不是同一个对象则返回结果 True,否则手游账号购买返回 False。

  代码样例:

  a=30

  b=30

  if a is b:

  print("a和b完全相同")

  else:

  print("a和b不同")

  if a is not b:

  print("a和b不同")

  else:

  print("a和b完全相同")

  # 修改变量 b 的值

  b=60

  if a is b:

  print("a和b完全相同")

  else:

  print("a和b不同")

  if a is not b:

  print("a和b不同")

  else:

  print("a和b完全相同")

  运行结果:

  a和b完全相同

  a和b完全相同

  a和b不同

  a和b不同

Statement of this Website
The copyright of this blog article belongs to the blogger. Please specify the address when reprinting! If there is any infringement or violation of the law, please contact admin@php.cn Report processing!
All comments Speak rationally on civilized internet, please comply with News Comment Service Agreement
0 comments
Author's latest blog post