How to convert an integer to a octal string in Python?


We have use oct() function from Python’s library to convert any integer to its octal equivalent number. We get a string having octal representation

>>> oct(100)
'0o144'
>>> oct(0x10)
'0o20'
>>> oct(10)
'0o12'


Updated on: 25-Feb-2020

312 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements