python encode hex pad every character with 00
问题 I need to pad every character with 00 for a string that I am converting to hex. Is there any way to do this in python 2.5.2? e.g. hextext = "H:\myfilepath.myfileending" encodedhex = str(hextext.encode('hex')) print encodedhex It currently prints 483a5c6d7966696c65706174682e6d7966696c65656e64696e67 But it should print 48003a005c00 etc. Also, I was hoping for all characters to be upper case - is there any way to do this? Im also wondering why does hex sometimes get padded with 00s in this way?