Friday 24 September 2021

Python: Convert hexa value to octal

‘oct’ function is used to convert an integer number to an octal string prefixed with “0o”.

 

Example

res2 = oct(0x13)

 

Find the below working application.

 

oct_demo_2.py

 

res1 = oct(0x12)
res2 = oct(0x13)
res3 = oct(0x14)

print(res1)
print(res2)
print(res3)

 

Output

0o22
0o23
0o24

 


  

Previous                                                    Next                                                    Home

No comments:

Post a Comment