- 6
- 0
- 约1.88千字
- 约 3页
- 2023-08-29 发布于上海
- 举报
pythonor的⽤法_pythonandor⽤法详解
and 和 or 是python的两个逻辑运算符,可以使⽤and , or来进⾏多个条件内容的判断。下⾯通过代码简单说明下and or的⽤法:
1. or:当有⼀个条件为真时,该条件即为真。逻辑图如下:
测试代码如下:
a=raw_input(please input somting:)
if a==a or a==b:
print it is a or b
else:
print it is not a or b
执⾏代码,输⼊a,b,ac,结果如下:
please input somting:a
it is a or b
please input somting:b
it is a or b
please input somting:ac
it is not a or b
通过这个例⼦,我们可以看出,当输⼊为a或者b时,满⾜ a==‘a或者a==b的条件,即满⾜if条件。
2.or:当所有条件为真时,该条件即为真。逻辑图如下:
测试代码如下:
a=raw_input(please input somting:)
if a!=a and a!=b:
print it is not a or b
else:
print it i
您可能关注的文档
最近下载
- AIDC 800V直流供配电系统解决方案技术白皮书.pdf
- 国家基本药物培训课件.pptx VIP
- 《非煤矿山开工第一课》专题讲座.pptx
- 2026年四川省党政领导干部政治理论水平凡提必考(理论考试)强化练习题及答案.docx VIP
- 羽毛球大众C级教练员培训考试大纲真题.docx VIP
- 竞争性谈判谈判文件模板.doc VIP
- 15ZD03 室外箱式变电站安装.pdf VIP
- 新编大学英语(第四版)综合教程2教学课件B2U7 Reading 1.pptx VIP
- 基于PLC的自动化生产线控制系统设计.docx VIP
- 2025年四川能投兴文电力有限公司招聘笔试历年参考题库附带答案详解.docx VIP
原创力文档

文档评论(0)