OK、私は一般的にファイルを扱うのはかなり新しいです.Pythonでファイルを操作できるように、ファイル仕様から情報を取得する方法を教えてくれるチュートリアルを持っている人はいますか? 私は将来のためにこれを一般的に行う方法を学びたいと思っていますが、特に私が今興味を持っている形式はcall sffであり、基本的には各フレームに関する情報を含むpcx画像を含むアーカイブのタイプです。最終目標は私が欲しいですそれを解凍し、pcx のサブグループをアニメーション gif に変換します (最後の部分は既に実行できます。現在、sff を解凍する方法を見つけようとしています)。Python ドキュメントからのバイナリ ファイルの読み取りと、シーク読み取りとストライク アンパックの使用に関する情報をまとめようとしましたが、期待どおりに機能しないようです。今、私は立ち往生していますseek(24)
read(4)
(それは次のサブヘッダーの場所を与えるはずです)、そして\x00\x02\x00\x00
. 私が推測するのは16進数です(しかし、Pythonにそれを教えてもらう方法がわかりません)。だから私はチュートリアルを探していますが、具体的な答えも大歓迎です。ありがとう。
これが私が持っている仕様です:
/*--| SFF file structure
|--------------------------------------------------*\
Version 1.01
HEADER (512 bytes)
------
Bytes
00-11 "ElecbyteSpr\0" signature [12]
12-15 1 verhi, 1 verlo, 1 verlo2, 1 verlo3 [04]
16-19 Number of groups [04]
20-24 Number of images [04]
24-27 File offset where first subfile is located [04]
28-31 Size of subheader in bytes [04]
32 Palette type (1=SPRPALTYPE_SHARED or 0=SPRPALTYPE_INDIV) [01]
33-35 Blank; set to zero [03]
36-511 Blank; can be used for comments [476]
SUBFILEHEADER (32 bytes)
-------
Bytes
00-03 File offset where next subfile in the "linked list" is [04]
located. Null if last subfile
04-07 Subfile length (not including header) [04]
Length is 0 if it is a linked sprite
08-09 Image axis X coordinate [02]
10-11 Image axis Y coordinate [02]
12-13 Group number [02]
14-15 Image number (in the group) [02]
16-17 Index of previous copy of sprite (linked sprites only) [02]
This is the actual
18 True if palette is same as previous image [01]
19-31 Blank; can be used for comments [14]
32- PCX graphic data. If palette data is available, it is the last
768 bytes.
*--------------------------------------------------------------------------*/