Python:Numbers

From wiki
Jump to navigation Jump to search

NOTE: Numbers starting with 0 are interpreted as octal number.

Look at this:

>>> a = 0123
>>> print(a)
83
>>> type(a)
<type 'int'>
int(x)
Convert x into an integer
hex(x)
Convert x into an hexadecimal number 0x....
oct(x)
Convert x into an octal number 0....

See Python:Strings#Advanced for conversions by format.