アーカイブ
Posts Tagged ‘python’
33. Clojure: Big EndianとLittle Endianのデータファイルを作成
2010/12/27
コメントを残す
clojureでファイル解析を行う練習をしてみたいので、簡単にテストデータを作っておく。pythonで。
#!/usr/bin/env python from __future__ import with_statement from struct import pack #Little Endian with file("little-endian.dat", "w") as f: f.write(pack('<H', 0x1234)) f.write(pack('<I', 0x12345678)) # Big Endian with file("big-endian.dat", "w") as f: f.write(pack('>H', 0x1234)) f.write(pack('>I', 0x12345678))