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.
バイトに続いてロングをパックしたい。私のバッファーには 9 つの要素しか含めることができません。それらをバッファにパックできないのはなぜですか?
>>> from struct import * >>> calcsize('qB') 9 >>> calcsize('Bq') 12
返し方が違います。どうしてこれなの?
ところで、私はPython 2.7.3を使用しています。
2 番目の例でstruct.calcsizeは、long long が 4 バイト境界で開始できるように、バイトの後に 3 バイトのパディングを想定しています。
struct.calcsize
パディングを指定しない場合、それらは同等であることがわかります。
>>> calcsize ('Bq') 12 >>> calcsize('=Bq') 9