Home >Backend Development >Python Tutorial >What does int mean in python?
Students who learn python may have this question, why does the statement int(10) exist in python, since a=10 and a=int(10) have the effect The same, then there is no need to exist int(10), then let us take a look at the following picture
As you can see from the picture, we write in the code a=10, in fact, the computer still has to call the constructor of int in the end, which means that a=10 will eventually become a=int(10) in the computer. If you don’t understand, let’s take a look at the internal constructor prototype of int. def init(self,x,base): There are three parameters in it. The first parameter self: refers to the current object, x: refers to the data input by the console, base: indicates the decimal number of the current number, if not written , the default base=decimal, for example: int('1010001',2) this code is parsed as: x=1010001,base=2
The final code will be converted into 10 format and output.
The above is the detailed content of What does int mean in python?. For more information, please follow other related articles on the PHP Chinese website!