身份运算符/流程控制if

时间:2020-03-07 13:27:18   收藏:0   阅读:58

身份运算符

in

print("e" in "hello eogn")

True

print(‘z‘ in [‘c‘,‘y‘,‘z‘])

True

print(‘k1‘ in {‘k1‘:666,‘k2‘:01})
print(01 in {‘k1‘:666,‘k2‘:01})

True
False

  

not in

判断一个字符或者字符串是否存在于一个大字符串中/元素/key

 

print("e" not in "hello eogn")

False



print(‘z‘ not in [‘c‘,‘y‘,‘z‘])

False

print(‘k1‘ in {‘k1‘:666,‘k2‘:01})
print(01 in {‘k1‘:666,‘k2‘:01})

False
True

  

 

身份运算符  is / not is

x = 1
y = 1
print(x is y)

True

  

x = 1
y = 1
print(x is not y)

False

  

    if  的语法。

 

原文:https://www.cnblogs.com/Tornadoes-Destroy-Parking-Lots/p/12433524.html

评论(0
© 2014 bubuko.com 版权所有 - 联系我们:wmxa8@hotmail.com
打开技术之扣,分享程序人生!