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

如题所述

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

温馨提示:答案为网友推荐,仅供参考
相似回答