hex()

hex(x)

Convert an integer number to a lowercase hexadecimal string prefixed with “0x”, for example:

>>> hex(255)
'0xff'
>>> hex(-42)
'-0x2a'

If x is not a Python int object, it has to define an __index__() method that returns an integer.

See also int() for converting a hexadecimal string to an integer using a base of 16.

Note

To obtain a hexadecimal string representation for a float, use the float.hex() method.

doc_python
2016-10-07 17:33:43
Comments
Leave a Comment

Please login to continue.