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: 2020-02-25T11:22:01+05:30

487 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements