Returns the hexadecimal representation of the given number.
- Use
hex()
to convert a given decimal number into its hexadecimal equivalent.
代码实现
def to_hex(dec):
return hex(dec)
使用样例
to_hex(41) # 0x29
to_hex(332) # 0x14c
Returns the hexadecimal representation of the given number.
hex()
to convert a given decimal number into its hexadecimal equivalent.
def to_hex(dec):
return hex(dec)
to_hex(41) # 0x29
to_hex(332) # 0x14c