我在python3中有两个类bytes
的变量。你知道吗
print(string1) --> b'2900BCE03604093C000080'
print(bytes.fromhex(string1.decode('utf8'))) --> b')\x00\xbc\xe06\x04\t<\x00\x00\x80'
print(type(string1)) --> <class 'bytes'>
print(type(bytes.fromhex(string1.decode('utf8')))) --> <class 'bytes'>
第二个输出中出现奇怪的值是因为某些十六进制值的ascii解释。你知道吗
我的问题是如何更容易地将string1
转换为第二行的输出。有更好的办法吗?你知道吗
可以使用^{} 函数获取二进制数据的十六进制表示形式:
相关问题 更多 >
编程相关推荐