gpt4 book ai didi

python - "a is a is a"比较结果

转载 作者:太空狗 更新时间:2023-10-29 17:55:45 26 4
gpt4 key购买 nike

<分区>

A = 314

if A == A == A:
print('True #1')

if A == A == 271:
print('True #2')

lie = 0
if lie is lie is lie:
print('no matter how white, how small,')
print('how incorporating of a smidgeon')
print('of truth there be in it.')

结果:

True #1
no matter how white, how small,
how incorporating of a smidgeon
of truth there be in it.

我知道在 if 语句中使用两个“=”和“is”是不正常的。但我想知道 Python 解释器如何解释 if 语句。

表达式lie is lie is lie是同时解释的,还是短路的方式?

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com