I've got a list of hex strings.
mylist = ['0xff', '0x34', '0x95', '0x11']
I'd like to get this list into another list, but in hex format. Thus the list should look something like this.
myhexlist = ['\xff', '\x34', '\x95', '\x11']
What I've tried:
#!/usr/bin/env python
myhexlist = []
mylist = ['0xff', '0x34', '0x95', '0x11']
for b in mylist:
myhexlist.append( hex(int(b,16)) )
print myhexlist
Which does not produce the desired output.
0xwith\x? For example,myhexlist = [i.replace("0x", "\\x") for i in mylist].