Python OCT function

Time:2020-11-25

 

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:

oct(x)

 

Parameters:

X – integer;

Return value: return octal data corresponding to integer;

 

2、 Use of OCT function

>>>oct(10)
'012'
>>> oct(20)
'024'
>>> oct(15)
'017'
>>>

 

 

Note the difference from the ord / Chr function

1. Chr function converts ascll code into character

chr(65)
>>>> "A"

 

 

 

2. The ord function converts characters into ascll codes

ord("A")
>>>> 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
python教程公众号
Python
WeChat official account swept the attention