first, the introduction
This is what I was inspired to learn from the 28th page of the book "Python Algorithms 2nd":
For intergral weights, your could use Sys.maxint, even though it ' s not guaranteed to is the greatest possbile value (long INTs can be longer).
We say less, direct test code:
Import sys
print (sys.maxint)
We look forward to thinking that we can output the largest integer value, and found the error:
Traceback (most recent call last):
File "", Line 1, in
Attributeerror:module ' sys ' has no attribute ' maxint '
So, what is this for? Second, explore
The Chinese community has little to do with this issue, so I found a description of the foreign friends on StackOverflow:
The Sys.maxint constant was removed, since there are no longer a limit to the value of integers. However, sys.maxsize can be used as a integer larger than any pratical list or string index. It conforms to the implementation ' natural ' integer size and are typically the same as Sys.maxint in previous releases on The same platform (assuming the same build options).
That is, in a new release, Sys.maxint has been removed because there is no limit to integer values. However, the standard provides a sys.maxsize to represent a larger integer value than any of our actual work can represent. This value is exactly the same as the original sys.maxint.
Well, let's test this:
Import sys
print (sys.maxsize)
On my machine, the results of the operation are:
9223372036854775807
In addition, to express the largest floating-point value, you can:
Print (float (' inf '))
Output of the expression above:
Inf
Used to express infinitely large floating-point values. Third, summary
is actually two words:
Sys.maxsize
Float (' inf ')
Easy to remember, easy to use:)