赞
踩
I am looking for minimum and maximum values for integers in python. For eg., in Java, we have Integer.MIN_VALUE and Integer.MAX_VALUE. Is there something like this in python?
解决方案
Python 3
In Python 3, this question doesn't apply. The plain int type is unbounded.
However, you might actually be looking for the machine's
Python 2
In Python 2, the maximum value for plain int values is available as sys.maxint:
>>> sys.maxint
9223372036854775807
You can calculate the minimum value with -sys.maxint - 1 as shown here.
Python seamlessly switches from plain to long integers once you exceed this value. So most of the time, you won't need to know it.
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。