w3resource
w3resource logo

Python: oct() function

(追記) (追記ここまで)
(追記) (追記ここまで)

oct() function

The oct() function is used to convert an integer number to an octal string.

Octal strings in Python are prefixed with 0o.

Version:

(Python 3.2.5)

Syntax:

oct(x)

Parameter:

Name Description Required /
Optional
x An integer. Required

Return value:

Returns an octal string from the given integer number.

Example: Python oct() function

# decimal number
print('oct(11) is:', oct(11))
# binary number
print('oct(0b110) is:', oct(0b110))
# hexadecimal number
print('oct(0XB) is:', oct(0XB))

Output:

oct(11) is: 0o13
oct(0b110) is: 0o6
oct(0XB) is: 0o13

Pictorial Presentation:

Python: Built-in-function - oct() function

Pictorial Presentation:

Python: Built-in-function - oct() function

Pictorial Presentation:

Python: Built-in-function - oct() function

Python Code Editor:

[フレーム]

PREV : object()
NEXT : open()

Test your Python skills with w3resource's quiz



Follow us on Facebook and Twitter for latest update.

(追記) (追記ここまで)


(追記) (追記ここまで)
(追記) (追記ここまで)


AltStyle によって変換されたページ (->オリジナル) /