Home  >  Article  >  Backend Development  >  What does int mean in python?

What does int mean in python?

silencement
silencementOriginal
2019-06-22 13:06:459381browse

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

What does int mean in python?

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!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn