Home>Article>Backend Development> python int function usage
python int function usage
Description
int() function is used to convert a character Convert string or number to integer type.
Recommended: "python tutorial"
Grammar
The following is the syntax of the int() method:
class int(x, base=10)
Parameters
x -- string or number.
base -- base number, default decimal.
Return value
Return integer data.
Example
The following shows an example of using the int() method:
>>>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
The above is the detailed content of python int function usage. For more information, please follow other related articles on the PHP Chinese website!