python,可以举个例子吗

2025-05-01 01:58:58
推荐回答(1个)
回答1:

not表示取反啊,相当于C语言中的非(!),例如:123456# 因为x为True,所以输出结果为1x = Trueif x: print 1else: print 2123456# 因为x为True,not x 就是False了,所以输出结果为2x = Trueif not x: print 1else: print 2