Python data base conversion and digit completion

1. Shaping hexadecimal conversion

hex(255)

2. Shaping hexadecimal conversion, remove 0x

hex(255).replace('0x', '')

3. One digit prints two digits with 0

'1'.zfill(2)

4.demo

if __name__ == '__main__':
    print(hex(255))
    print(hex(255).replace('0x', ''))
    print('1'.zfill(2))
    print('11'.zfill(2))

5. Show

Guess you like

Origin blog.csdn.net/qq_41854291/article/details/108488551