CKTIS / Python
hex()
Scrive un intero in esadecimale con lettere minuscole e prefisso 0x.
Versione: Python 3.14; repository image, production runtime not attested
Sintassi
hex(integer, /)Scrive un intero in esadecimale con lettere minuscole e prefisso 0x.
Due f rappresentano 15 · 16 + 15 = 255. Per −16 il segno precede 0x10. Larghezza minima e maiuscole si impostano con format.
Sono ammessi i tipi con __index__.
assert hex(255) == "0xff" and hex(-16) == "-0x10"
assert format(15, "04X") == "000F" and format(0x12345, "04X") == "12345"
Esempi
print(hex(255))
print(hex(-16))
Risultato
0xff -0x10
Sono ammessi i tipi con `__index__`.