Python's built-in function int()

class int(x, base=10)

Returns an integer object. 0 is returned by default.

The parameter x can be a string or a floating point number.

Base refers to the hexadecimal form of x, such as 2 for binary and 10 for decimal. In particular, it should be noted that 0 represents any base.

Copy code

>>> int('123',10)
123
>>> int('123',0)
123
>>> int('0x123',16)
291
>>> int('0x123',0)
291

Copy code

Guess you like

Origin blog.csdn.net/zilan23/article/details/106973062