Friday 24 September 2021

Python: Convert octal to hexa value

‘hex()’ function is used to convert an integer number to a lowercase hexadecimal string prefixed with “0x”.

 

Example

res1 = hex(0o22)

 

Find the below working application.

 

hex_demo_1.py

# Convert octal to hexa
res1 = hex(0o22)

print(res1)

 

Output

0x12

 


  

Previous                                                    Next                                                    Home

No comments:

Post a Comment