>>> i=0 >>> for a in "EH\01\01": ... i=(i<<8)+ord(a) ... >>> i 1162346753 >>> '{:x}'.format(i) '45480101'