Saturday, March 24, 2012

Python - Converting character string to HEXA string

ord(c): Given a string of length one, return an integer representing the Unicode code point of the character when the argument is a unicode object, or the value of the byte when the argument is an 8-bit string.

hex(n): Convert an integer number to a hexadecimal string

We do not need first to characters in the hex output.

zfill(witdh): Return the numeric string left filled with zeros in a string of length width.

Put of together,