Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

The Python oct() function

The Python oct() function

Python built-in function Python built-in function


Description

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

Syntax

oct syntax:


oct(x)

Parameter Description:

Return Value

Returns an octal string.

Example

The following examples demonstrate how to use 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 function Python built-in function