Analysis of int () function usage in Python, pythonint
Int () is an internal function of Python.
This is what we say in the Python help.
>>> help(int) Help on class int in module __builtin__: class int(object) | int(x[, base]) -> integer | | Convert a string or number to an integer, if possible. A floating point | argument will be truncated towards zero (this does not include a string | representation of a floating point number!) When converting a string, use | the optional base. It is an error to supply a base when converting a | non-string. If base is zero, the proper base is guessed based on the | string content. If the argument is outside the integer range a | long object will be returned instead. >>> int(12.0) 12
The int () function can convert a number into an integer.
>>> int('12',16) 18
There are two points to note: 1) 12 the input must be in the form of a string, if the base parameter is included
2) here 12 is not converted to a hexadecimal number, but 12 is a hexadecimal number. The int () function is expressed in decimal number, as shown below:
>>> int('0xa',16) 10 >>> int('10',8) 8
Summary
The above section describes how to use the int () function in Python. I hope it will help you. If you have any questions, please leave a message and I will reply to you in a timely manner. Thank you very much for your support for the help House website!