社区所有版块导航
Python
python开源   Django   Python   DjangoApp   pycharm  
DATA
docker   Elasticsearch  
aigc
aigc   chatgpt  
WEB开发
linux   MongoDB   Redis   DATABASE   NGINX   其他Web框架   web工具   zookeeper   tornado   NoSql   Bootstrap   js   peewee   Git   bottle   IE   MQ   Jquery  
机器学习
机器学习算法  
Python88.com
反馈   公告   社区推广  
产品
短视频  
印度
印度  
私信  •  关注

Nithin Varghese

Nithin Varghese 最近创建的主题
Nithin Varghese 最近回复了
7 年前
回复了 Nithin Varghese 创建的主题 » 与python列表一起使用的and运算符[重复]

执行布尔逻辑,但它们在比较时返回一个实际值。使用时 ,从左到右在布尔上下文中计算值。 0,,,[],(),{}, 没有 在布尔上下文中为false;其他都为true。

如果在布尔上下文中所有值都为true, 返回最后一个值。

>>> 2 and 5
5
>>> 2 and 5 and 10
10

如果布尔上下文中的任何值为false 返回第一个假值。

>>> '' and 5
''
>>> 2 and 0 and 5
0

所以代码

return len(args) and max(args)-min(args)

返回的值 max(args)-min(args) 如果有的话 阿尔茨海默病 否则它会回来 len(args) 哪一个是0。