Python oct() Funktion
Beschreibung
oct()Die Funktion wandelt eine Ganzzahl in einen Oktalstring um.
- In Python 2.x wird Oktal mit0als Präfix dargestellt.
- In Python 3.x wird Oktal mit0oals Präfix dargestellt.
Syntax
oct-Syntax:
oct(x)
Parameter description:
- x -- Ganzzahl.
Rückgabewert
Gibt einen Oktalstring zurück.
Beispiel
Das folgende Beispiel demonstriert die Verwendung von oct:
Beispiel (Python 2.0+)
>>> oct(10)
'012'
>>> oct(20)
'024'
>>> oct(15)
'017'
'012'
>>> oct(20)
'024'
>>> oct(15)
'017'
Beispiel (Python 3.0+)
>>> oct(10)
'0o12'
>>> oct(20)
'0o24'
>>> oct(15)
'0o17'
'0o12'
>>> oct(20)
'0o24'
>>> oct(15)
'0o17'
Python Built-in-Funktionen