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.

 

posted @ 2015-01-22 23:27  valentine is me  阅读(354)  评论(0编辑  收藏  举报