[英]In python, how to convert a hex ascii string to raw internal binary string?
[英]How can I convert a python binary string to hex?
binary_str = b'\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00'
如何在 python 中將此二進制數據轉換為十六進制數據?
我試過這樣,但它不工作。
>>> hex(b'\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: 'bytes' object cannot be interpreted as an integer
在 python 中, hex
不能這樣工作。 試試這樣:
binary_str = b'\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00'
print(binary_str.hex())
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.