The Python hex() function
Description
hex() The function converts a decimal integer to a hexadecimal string.
Syntax
hex syntax:
hex(x)
Parameter Description:
- x -- a decimal integer
Return Value
Returns a hexadecimal number as a string.
Example
The following examples demonstrate how to use hex:
hex
(
255
)
'
0xff
'
hex
(
42
)
'
-0x2a
'
hex
(
1L
)
'
0x1L
'
hex
(
12
)
'
0xc
'
type
(
hex
(
12
)
)
<
class
'
str
'
Python built-in function