Home > Backend Development > Python Tutorial > What does int mean in python

What does int mean in python

Release: 2019-07-08 09:03:09
Original
83500 people have browsed it

What does int mean in python

int has two meanings in Python: first, it represents a numeric type of Python (signed integer type); second, it represents a built-in function int() function of Python. Used to convert a string or number to an integer.

Syntax:

class int(x, base=10)
Copy after login

Parameters:

x -- 字符串或数字。base -- 进制数,默认十进制。
返回值:
返回整型值。
>>>int()               # 不传入参数时,得到结果0
0
>>> int(3)
3
>>> int(3.6)
3
>>> int('12',16)        # 如果是带参数base的话,12要以字符串的形式进行输入,12 为 16进制
18
>>> int('0xa',16)
10
>>> int('10',8)  
8
Copy after login

For more Python related technical articles, please visit the Python Tutorial column to learn!

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!

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template