栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 软件开发 > 后端开发 > Python

python--比较运算符 布尔运算符 not ,in ,not in

Python 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

python--比较运算符 布尔运算符 not ,in ,not in

比较 < <= == != > >=(比较的是值)

a,b=20,32
print("a 

lst1=[11,22,33,44]
lst2=[11,22,33,44]
print(lst1==lst2)#说明值相同
print(id(lst1))
print(id(lst2))
print(lst1 is lst2 )#s说明id不同
print(lst1 is not lst2 )#s说明id不同

布尔and

#and 都为真 才是真
a,b=1,2
print(a==1 and b==2)#true true =true
print(a==1 and b<2)#true false =false
print(a!=1 and b<2)#false false =false
print(a!=1 and b==2)#false true =false

布尔 or

#or 只有一个为真就行
a,b=1,2
print(a==1 or b==2)#true true =true
print(a==1 or b<2)#true false =true
print(a!=1 or b<2)#false false =false
print(a!=1 or b==2)#false true =true

#not bool取反
a=True
print(not a)

 in not in 

#是不是在字符串内部
a="sdgjxnal"
print("w" in a)
print("s" in a)
print("y" not in a)

转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/942610.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号