Next / Previous / Contents / TCC Help System / NM Tech homepage

20.29. oct(): Convert to base 8

Given a number n, oct(n) returns a string containing an octal (base 8) representation of n. Consistent with Python's convention that any number starting with a zero is considered octal, the result of this function will always have a leading zero.

>>> oct(0)
>>> oct(127)

See also Section 9.4, “The string .format() method”: octal conversion is supported by specifying type code 'o'.