COMTIBoy
February 4th, 2009, 04:07 AM
Hi Everyone,
I'm new to Python.
I have just assigned the following string to x. (x was read from a file)
x = 'F0F0F1F1F0F0F1F1'
but I would like to transpose x to this:
'\xF0\xF0\xF1\xF1\xF0\xF0\xF1\xF1'
I was thinking about creating a function that would take a string (e.g. x) as input and return '\xF0\xF0\xF1\xF1\xF0\xF0\xF1\xF1' as output.
Just not sure what's the most efficient way to put the '\x' in front of each hex value.
Any tips for a new comer is surely welcomed !
THanks,
I'm new to Python.
I have just assigned the following string to x. (x was read from a file)
x = 'F0F0F1F1F0F0F1F1'
but I would like to transpose x to this:
'\xF0\xF0\xF1\xF1\xF0\xF0\xF1\xF1'
I was thinking about creating a function that would take a string (e.g. x) as input and return '\xF0\xF0\xF1\xF1\xF0\xF0\xF1\xF1' as output.
Just not sure what's the most efficient way to put the '\x' in front of each hex value.
Any tips for a new comer is surely welcomed !
THanks,