Python - string to hexbytes conversion - help

Jason Orendorff jason at jorendorff.com
Wed Dec 5 17:05:13 EST 2001


"me" wrote:
> I'm a newbie to Python and I am trying to convert a string of
> decimal numbers - read from raw_input to a series of hexbytes

def convert(src):
    result = ''
    for i in range(0, len(src), 2):
        slice = src[i:i+2]
        n = int(slice, 16)
        result += chr(n)
    return result

I think this is what you want but it's hard to tell from your
post.

-- 
Jason Orendorff
http://www.jorendorff.com/





More information about the Python-list mailing list