天天看点

python 浮点数和整数的比较

举个栗子:

#!/usr/bin/env python
# encoding: utf-8
a = 10
b = 10
c = 100
d = 100
e = 10.0
f = 10.0
print(a is b)
print(c is d)
print(e is f)
print(a == e)
print(a is e)
           

输出的结果为

True
True
True
True
False
           

注意第4个和第5个比较的公式,结果不必多说。