I wrote this simple function:
def padded_hex(i, l): given_int = i given_len = l hex_result = hex(given_int)[2:] # remove \'0x\' from beginning o
What I needed was
"{:02x}".format(2) # '02' "{:02x}".format(42) # '2a'
or as f-strings:
f"{2:02x}" # '02' f"{42:02x}" # '2a'