python3.4 Example of converting hexadecimal to string

  • 2021-06-28 13:05:39
  • OfStack

Convert 16-bit received by socket to string


def hex_to_str(b):

  s = ''
  for i in b:
    s += '{0:0>2}'.format(str(hex(i))[2:])
  return(s)

Related articles: