Easy Tutorial
❮ Python Os Utime Python String Index ❯

Python oct() Function

Python Built-in Functions


Description

The oct() function converts an integer to an octal string.

Syntax

The syntax for oct is:

oct(x)

Parameter:

Return Value

Returns an octal string.

Examples

The following examples demonstrate the use of oct:

Example (Python 2.0+)

>>> oct(10)
'012'
>>> oct(20)
'024'
>>> oct(15)
'017'

Example (Python 3.0+)

>>> oct(10)
'0o12'
>>> oct(20)
'0o24'
>>> oct(15)
'0o17'

Python Built-in Functions

❮ Python Os Utime Python String Index ❯