Skip to content
Advertisement

How to print hex to the screen in python

I am trying to get python to print a hex string to the screen and not convert it to the ascii character.

JavaScript

Is there a way to print this to the screen as 'x5ex2ex6d' instead of '^.m'

Any help will be greatly appreciated.

Advertisement

Answer

b'x5ex2ex6d' and b'^.m' are identical as far as Python is concerned. However, you can format it as you desire like this:

JavaScript

or in Python3

JavaScript

or in Python2

JavaScript
User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement