Python OCT function



OCT function is also a python built-in function. It mainly converts an integer into octal, which is similar to ord function / Chr function;

1、 Introduction to OCT function

The oct() function converts an integer into an octet string. The syntax is as follows:




X – integer;

Return value: return octal data corresponding to integer;


2、 Use of OCT function

>>> oct(20)
>>> oct(15)



Note the difference from the ord / Chr function

1. Chr function converts ascll code into character

>>>> "A"




2. The ord function converts characters into ascll codes

>>>> 65





Guess you like it:

1. The difference and use of Python Chr / ord function

2. Python list derivation (classic code)

3. Python dictionary derivation (classic code)


Please note: Python OCT function


Please contact the blogger directly for technical exchange and business cooperation
Scan code or search: ape says Python
WeChat official account swept the attention