合规国际互联网加速 OSASE为企业客户提供高速稳定SD-WAN国际加速解决方案。 广告
### 导航 - [索引](../genindex.xhtml "总目录") - [模块](../py-modindex.xhtml "Python 模块索引") | - [下一页](uu.xhtml "uu --- Encode and decode uuencode files") | - [上一页](binascii.xhtml "binascii --- 二进制和 ASCII 码互转") | - ![](https://box.kancloud.cn/a721fc7ec672275e257bbbfde49a4d4e_16x16.png) - [Python](https://www.python.org/) » - zh\_CN 3.7.3 [文档](../index.xhtml) » - [Python 标准库](index.xhtml) » - [互联网数据处理](netdata.xhtml) » - $('.inline-search').show(0); | # [`quopri`](#module-quopri "quopri: Encode and decode files using the MIME quoted-printable encoding.") --- Encode and decode MIME quoted-printable data **Source code:** [Lib/quopri.py](https://github.com/python/cpython/tree/3.7/Lib/quopri.py) \[https://github.com/python/cpython/tree/3.7/Lib/quopri.py\] - - - - - - This module performs quoted-printable transport encoding and decoding, as defined in [**RFC 1521**](https://tools.ietf.org/html/rfc1521.html) \[https://tools.ietf.org/html/rfc1521.html\]: "MIME (Multipurpose Internet Mail Extensions) Part One: Mechanisms for Specifying and Describing the Format of Internet Message Bodies". The quoted-printable encoding is designed for data where there are relatively few nonprintable characters; the base64 encoding scheme available via the [`base64`](base64.xhtml#module-base64 "base64: RFC 3548: Base16, Base32, Base64 Data Encodings; Base85 and Ascii85") module is more compact if there are many such characters, as when sending a graphics file. `quopri.``decode`(*input*, *output*, *header=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](../glossary.xhtml#term-file-object). 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**](https://tools.ietf.org/html/rfc1522.html) \[https://tools.ietf.org/html/rfc1522.html\]: "MIME (Multipurpose Internet Mail Extensions) Part Two: Message Header Extensions for Non-ASCII Text". `quopri.``encode`(*input*, *output*, *quotetabs*, *header=False*)Encode the contents of the *input* file and write the resulting quoted-printable data to the *output* file. *input* and *output* must be [binary file objects](../glossary.xhtml#term-file-object). *quotetabs*, a non-optional flag which controls whether to encode embedded spaces and tabs; when true it encodes such embedded whitespace, and when false it leaves them unencoded. Note that spaces and tabs appearing at the end of lines are always encoded, as per [**RFC 1521**](https://tools.ietf.org/html/rfc1521.html) \[https://tools.ietf.org/html/rfc1521.html\]. *header* is a flag which controls if spaces are encoded as underscores as per [**RFC 1522**](https://tools.ietf.org/html/rfc1522.html) \[https://tools.ietf.org/html/rfc1522.html\]. `quopri.``decodestring`(*s*, *header=False*)Like [`decode()`](#quopri.decode "quopri.decode"), except that it accepts a source [`bytes`](stdtypes.xhtml#bytes "bytes") and returns the corresponding decoded [`bytes`](stdtypes.xhtml#bytes "bytes"). `quopri.``encodestring`(*s*, *quotetabs=False*, *header=False*)Like [`encode()`](#quopri.encode "quopri.encode"), except that it accepts a source [`bytes`](stdtypes.xhtml#bytes "bytes") and returns the corresponding encoded [`bytes`](stdtypes.xhtml#bytes "bytes"). By default, it sends a `False` value to *quotetabs* parameter of the [`encode()`](#quopri.encode "quopri.encode") function. 参见 模块 [`base64`](base64.xhtml#module-base64 "base64: RFC 3548: Base16, Base32, Base64 Data Encodings; Base85 and Ascii85")Encode and decode MIME base64 data ### 导航 - [索引](../genindex.xhtml "总目录") - [模块](../py-modindex.xhtml "Python 模块索引") | - [下一页](uu.xhtml "uu --- Encode and decode uuencode files") | - [上一页](binascii.xhtml "binascii --- 二进制和 ASCII 码互转") | - ![](https://box.kancloud.cn/a721fc7ec672275e257bbbfde49a4d4e_16x16.png) - [Python](https://www.python.org/) » - zh\_CN 3.7.3 [文档](../index.xhtml) » - [Python 标准库](index.xhtml) » - [互联网数据处理](netdata.xhtml) » - $('.inline-search').show(0); | © [版权所有](../copyright.xhtml) 2001-2019, Python Software Foundation. Python 软件基金会是一个非盈利组织。 [请捐助。](https://www.python.org/psf/donations/) 最后更新于 5月 21, 2019. [发现了问题](../bugs.xhtml)? 使用[Sphinx](http://sphinx.pocoo.org/)1.8.4 创建。