Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
ソケットから次の形式の MAC アドレスを受信しています: 0024e865a023 (受信文字列.encode("hex") でバイナリから変換された 16 進数)
次のようなユーザーが読める形式に変換したいと思います: 00-24-e8-65-a0-23
そうする簡単な方法はありますか?
MAC アドレスを各ブロックの配列に分解し、それらを結合できます-。
-
mac = '0024e865a023' blocks = [mac[x:x+2] for x in xrange(0, len(mac), 2)] macFormatted = '-'.join(blocks)