从Python 3.5开始,这终于不再笨拙了:
>>> b'xdexadxbexef'.hex()'deadbeef'
并反向:
>>> bytes.fromhex('deadbeef')b'xdexadxbexef'也适用于可变
bytearray类型。
参考:https : //docs.python.org/3/library/stdtypes.html#bytes.hex

从Python 3.5开始,这终于不再笨拙了:
>>> b'xdexadxbexef'.hex()'deadbeef'
并反向:
>>> bytes.fromhex('deadbeef')b'xdexadxbexef'也适用于可变
bytearray类型。
参考:https : //docs.python.org/3/library/stdtypes.html#bytes.hex