Home>Article>Backend Development> What is int in python

What is int in python

silencement
silencement Original
2019-05-20 18:09:14 42031browse

What is int 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 same effect, then There is no need to exist int(10), so let us take a look at the following picture

What is int in python

As you can see from the picture, we write a=10 in the code , in fact, the computer still has to call the construction method of int in the end, that is to say, a=10 will eventually become a=int(10) in the computer. If you don’t understand, then 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. = decimal, for example: int('1010001',2) this code is parsed as: x=1010001, base=2

The final code will be converted into 10 form and output.

Related learning recommendations:python tutorial

The above is the detailed content of What is int 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