python3的and not怎么用?

and not是两个运算符,运算顺序参照优先级,加括号就好理解了:(choice=="taunt bear") and (not bear_moved), 先==,然后not,最后and。优先级参照(由低到高)
python3的and not怎么用?
elif a == b and not c:
这里的and not不是这么断的,and表示条件同时满足条件才执行,not是修饰c的,c是False,那not c就是True,反之亦然。
这句话的意识是,当a与b相等,同时not c为True才执行下面的代码。
not放在布尔型数据前面表示取反,真的变假的,假的变真的2019-03-22
and not是两个运算符,运算顺序参照优先级,加括号就好理解了:(choice=="taunt bear") and (not bear_moved), 先==,然后not,最后and。优先级参照(由低到高)

2019-03-22
mengvlog 阅读 13 次 更新于 2025-07-20 02:44:19 我来答关注问题0
檬味博客在线解答立即免费咨询

Python相关话题

Copyright © 2023 WWW.MENGVLOG.COM - 檬味博客
返回顶部