bytes对象的hex和fromhex
bytes对象的hex函数,用来将bytes对象的值转换成hexstr;
而fromhex函数,用来将hexstr导入bytes对象;
>>> str_hex = bytes.fromhex('a4007893')
>>> str_hex
b'\xa4\x00x\x93'
>>> type(str_hex)
<class 'bytes'>
>>>
>>>
>>> hh = bytes([0xa4,00,78,93]).hex()
>>> hh
'a4004e5d'
>>> type(hh)
<class 'str'>
版权声明:本文为weixin_44571402原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。