小编Sam*_*cht的帖子

为什么我没有得到布尔值?

>>> 'a' in 'aeiou' or 'steve'
True
>>> 'S' in 'Sam' and 'Steve'
'Steve'
>>> 'a' in 'aeiou' and 'steve'
'steve'
>>> 's' in 'aeiou' or 'AEIOU'
'AEIOU'
Run Code Online (Sandbox Code Playgroud)

我正在为一些学生上课,并对最后三个输出感到惊讶.我期待一个布尔值.任何人都可以对此有所了解吗?

python operators boolean-expression

4
推荐指数
1
解决办法
95
查看次数

为什么用elif语句代替if语句?

为什么我应该使用elif而不是一遍又一遍地使用if语句。我找不到有关此事的任何文档。先感谢您。

python

-7
推荐指数
1
解决办法
1128
查看次数

标签 统计

python ×2

boolean-expression ×1

operators ×1