python 浮点数和整数的比较

  • Post author:
  • Post category: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个比较的公式,结果不必多说。



版权声明:本文为qq_33811662原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。