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

  运算符

  描述

  实例

  in

  如果在指定列表中找到返回 True,否则返回 False。

  如果 a 在 b 序列中返回 True。

  not in

  如果在指定列表中没有找到返回 True,否则返回 False。

  如果 a 不在 b 序列中返回 True。

  买手游账号代码样例:

  x=10

  y=20

  numbers=[1, 2, 3, 4, 5]

  if x in numbers:

  print("变量x在numbers列表中")

  else:

  print("变量x不在numbers列表中")

  if y not in numbers:

  print("变量y不在numbers列表中")

  else:

  print("变量y在numbers列表中")

  # 修改变量 x 的值

  x=2

  if x in numbers:

  print("变量x在numbers列表中")

  else:

  print("变量x不在numbers列表中")

  运行结果:

  变量x不在numbers列表中

  变量y不在numbers列表中

  变量x在numbers列表中

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