Bye Bye Moore

PoCソルジャーな零細事業主が作業メモを残すブログ

バイトリテラル列の分解

実際のところ

標準ライブラリstructのunpackメソッドを使います。

import struct
struct.unpack('8B', b'\xff\xf8\x00\x00\x00\x00\x00\x00')[0]
#>> 255
struct.unpack('8B', b'\xff\xf8\x00\x00\x00\x00\x00\x00')[1]
#>> 248

参考もと

python - What does the 'b' character do in front of a string literal? - Stack Overflow
PythonでバイナリをあつかうためのTips - Qiita

RubyにはBinDataとかいう便利ライブラリがあったけど……??

shuzo-kino.hateblo.jp