a = 1 print hex(a)
The above gives me the output: 0x1
0x1
How do I get the output as 0x01 instead?
0x01
print "0x%02x"%a
x as a format means "print as hex". 02 means "pad with zeroes to two characters".
x
02