quopri --- MIME quoted-printable データのエンコードとデコード¶
ソースコード: Lib/quopri.py
このモジュールは RFC 1521: "MIME (Multipurpose Internet Mail Extensions) Part One: Mechanisms for Specifying and Describing the Format of Internet Message Bodies" で定義されている quoted-printable による伝送のエンコードおよびデコードを行います。 quoted-printable エンコーディングは比較的印字不可能な文字の少ないデータのために設計されています; 画像ファイルを送るときのように印字不可能な文字がたくさんある場合には、 base64 モジュールで利用できる base64 エンコーディングのほうがよりコンパクトになります。
- quopri.decode(input, output, header=False, *, strip_ws=False)¶
Decode the contents of the input file and write the resulting decoded binary data to the output file. input and output must be binary file objects. If the optional argument header is present and true, underscore will be decoded as space. This is used to decode "Q"-encoded headers as described in RFC 1522: "MIME (Multipurpose Internet Mail Extensions) Part Two: Message Header Extensions for Non-ASCII Text". If the optional argument strip_ws is true, trailing whitespace is stripped from each line, as required by RFC 2045.
バージョン 3.16.0a1 (unreleased) で変更: Added the strip_ws parameter.
- quopri.encode(input, output, quotetabs, header=False)¶
ファイル input の内容をエンコードして、その結果の quoted-printable データをファイル output に書き出します。 input および output は バイナリファイルオブジェクト でなければなりません。 quotetabs は、内容に含まれている空白とタブ文字をエンコードするかどうかを制御する必須のフラグで、真のときは空白文字をエンコードし、偽のときはエンコードしないままにしておきます。 RFC 1521 に従って、行末にある空白とタブ文字は常にエンコードされることに注意してください。 header は、空白を RFC 1522 に従ってアンダースコアにエンコードするかどうかを制御するフラグです。
- quopri.decodestring(s, header=False, *, strip_ws=False)¶
decode()に似ていますが、ソースbytesを受け取り、対応するデコードされたbytesを返します。バージョン 3.16.0a1 (unreleased) で変更: Added the strip_ws parameter.
- quopri.encodestring(s, quotetabs=False, header=False)¶
encode()に似ていますが、ソースbytesを受け取り、対応するエンコードされたbytesを返します。 デフォルトでは、encode()関数の quotetabs パラメータにFalseを渡します。
参考
base64モジュールMIME base64 形式データのエンコードおよびデコード