Python 不同数据类型比较

temp = '32'
if temp > 85:
   print "Hot"
elif temp > 62:
   print "Comfortable" 
else:
   print "Cold" 

 


结果输出为Hot.

Why?

Essentially, "...the choice whether one object is considered smaller or larger than another one is made arbitrarily but consistently" means that when comparing objects of different types (ex. string with an int) the choice of which to always be larger was made arbitrarily. In this case, any string is always bigger than any int.

 

转载于:https://www.cnblogs.com/valentineisme/p/4242981.html

你可能感兴趣的:(Python 不同数据类型比较)