0x%016llX from C to python?

Question:

I am using the following expression in C code:

sprintf(message, "0x%016llX; ", someIntValue);

How do I do the same in python?

I know in C what it means.

  1. the mandatory % character
  2. a 0 flag for padding
  3. the 16 as "minimum field width"
  4. the ll as "length modifiers"
  5. the x conversion specifier

What I don’t know, is how to do it in python…

Asked By: sam123

||

Answers:

The same can be achieved using either of the following:

"0x%016X; " % someIntValue            # Old style
"{:016X}; ".format( someIntValue )    # New style
Answered By: ikegami