Python Hexadecimal

前端 未结 3 1107
礼貌的吻别
礼貌的吻别 2020-11-29 00:50

How to convert decimal to hex in the following format (at least two digits, zero-padded, without an 0x prefix)?

Input: 255 Output:ff

3条回答
  •  孤城傲影
    2020-11-29 01:12

    Another solution is:

    >>> "".join(list(hex(255))[2:])
    'ff'
    

    Probably an archaic answer, but functional.

提交回复
热议问题