pythonor的用法_pythonandor用法详解.pdfVIP

  • 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

文档评论(0)

1亿VIP精品文档

相关文档