python布尔值判断,python中的not具体表示是什么,举个例子说

2025-04-08 21:04:33
推荐回答(1个)
回答1:

not表示取反啊,相当于C语言中的非(!),例如:

# 因为x为True,所以输出结果为1
x = True
if x:
print 1
else:
print 2
# 因为x为True,not x 就是False了,所以输出结果为2
x = True
if not x:
print 1
else:
print 2