簡體   English   中英

Python 中的字節數組(不是 bytearray 對象)

[英]Array of bytes in Python (not bytearray object)

我有以下格式的 MAC 地址:15302363377678(或十六進制的 0xdeadbeef00e)我如何將它表示為 Python 中的字節數組? 這里我想要十進制形式。

使用int.to_bytes()怎么樣? 它返回一個表示整數的字節數組

mac_address = (15302363377678).to_bytes(length=8, byteorder="big")
print(mac_address)
print(*mac_address)

輸出:

b'\x00\x00\r\xea\xdb\xee\xf0\x0e'
0 0 13 234 219 238 240 14

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM