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'



Advertisements