0

I need print hex value of '?' this character

currently, my script returns wierd characters such as '?' or '£☻ §"

I want to read them as proper hex value.

if choice == 8:
   incoming =ser.readline()     
   print incoming

Can anyone please help me with this?

Jerry Stratton
  • 3,287
  • 1
  • 22
  • 30
Priya Pawar
  • 21
  • 1
  • 8

1 Answers1

1

Take a look at this post: Print a string as hex bytes?

You ultimately need to encode each character as it's raw hex byte using c.encode('hex') where c is a character in your string.

Community
  • 1
  • 1
Preston
  • 2,543
  • 1
  • 17
  • 26