Перейти к содержанию

Python oct() built-in function

Python oct() built-in function

From the Python 3 documentation Convert an integer number to an octal string prefixed with “0o”. The result is a valid Python expression. If x is not a Python int object, it has to define an index() method that returns an integer.

Examples

>>> oct(1)
# '0o1'
>>> oct(10)
# '0o12'
>>> oct(100)
# '0o144'
>>> oct(1000)
# '0o1750'