<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                合規國際互聯網加速 OSASE為企業客戶提供高速穩定SD-WAN國際加速解決方案。 廣告
                ### 導航 - [索引](../genindex.xhtml "總目錄") - [模塊](../py-modindex.xhtml "Python 模塊索引") | - [下一頁](binhex.xhtml "binhex --- 對binhex4文件進行編碼和解碼") | - [上一頁](mimetypes.xhtml "mimetypes --- Map filenames to MIME types") | - ![](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); | # [`base64`](#module-base64 "base64: RFC 3548: Base16, Base32, Base64 Data Encodings; Base85 and Ascii85") --- Base16, Base32, Base64, Base85 數據編碼 **源代碼:** [Lib/base64.py](https://github.com/python/cpython/tree/3.7/Lib/base64.py) \[https://github.com/python/cpython/tree/3.7/Lib/base64.py\] - - - - - - 此模塊提供了將二進制數據編碼為可打印的 ASCII 字符以及將這些編碼解碼回二進制數據的函數。它為 [**RFC 3548**](https://tools.ietf.org/html/rfc3548.html) \[https://tools.ietf.org/html/rfc3548.html\] 指定的 Base16, Base32 和 Base64 編碼以及已被廣泛接受的 Ascii85 和 Base85 編碼提供了編碼和解碼函數。 [**RFC 3548**](https://tools.ietf.org/html/rfc3548.html) \[https://tools.ietf.org/html/rfc3548.html\] 編碼的目的是使得二進制數據可以作為電子郵件的內容正確地發送,用作 URL 的一部分,或者作為 HTTP POST 請求的一部分。其中的編碼算法和 **uuencode** 程序是不同的。 此模塊提供了兩個接口。新的接口提供了從 [類字節對象](../glossary.xhtml#term-bytes-like-object) 到 ASCII 字節 [`bytes`](stdtypes.xhtml#bytes "bytes") 的編碼,以及將 ASCII 的 [類字節對象](../glossary.xhtml#term-bytes-like-object) 或字符串解碼到 [`bytes`](stdtypes.xhtml#bytes "bytes") 的操作。此模塊支持定義在 [**RFC 3548**](https://tools.ietf.org/html/rfc3548.html) \[https://tools.ietf.org/html/rfc3548.html\] 中的所有 base-64 字母表 (普通的、URL 安全的和文件系統安全的)。 舊的接口不提供從字符串的解碼操作,但提供了操作 [文件對象](../glossary.xhtml#term-file-object) 的編碼和解碼函數。舊接口只支持標準的 Base64 字母表,并且按照 [**RFC 2045**](https://tools.ietf.org/html/rfc2045.html) \[https://tools.ietf.org/html/rfc2045.html\] 的規范每 76 個字符增加一個換行符。注意:如果你需要支持 [**RFC 2045**](https://tools.ietf.org/html/rfc2045.html) \[https://tools.ietf.org/html/rfc2045.html\],那么使用 [`email`](email.xhtml#module-email "email: Package supporting the parsing, manipulating, and generating email messages.") 模塊可能更加合適。 在 3.3 版更改: 新的接口提供的解碼函數現在已經支持只包含 ASCII 的 Unicode 字符串。 在 3.4 版更改: 所有 [類字節對象](../glossary.xhtml#term-bytes-like-object) 現在已經被所有編碼和解碼函數接受。添加了對 Ascii85/Base85 的支持。 新的接口提供: `base64.``b64encode`(*s*, *altchars=None*)對 [bytes-like object](../glossary.xhtml#term-bytes-like-object) *s* 進行 Base64 編碼,并返回編碼后的 [`bytes`](stdtypes.xhtml#bytes "bytes")。 可選項 *altchars* 必須是一個長 2 字節的 [bytes-like object](../glossary.xhtml#term-bytes-like-object),它指定了用于替換 `+` 和 `/` 的字符。這允許應用程序生成 URL 或文件系統安全的 Base64 字符串。默認值是 `None`,使用標準 Base64 字母表。 `base64.``b64decode`(*s*, *altchars=None*, *validate=False*)解碼 Base64 編碼過的 [bytes-like object](../glossary.xhtml#term-bytes-like-object) 或 ASCII 字符串 *s* 并返回解碼過的 [`bytes`](stdtypes.xhtml#bytes "bytes")。 可選項 *altchars* 必須是一個長 2 字節的 [bytes-like object](../glossary.xhtml#term-bytes-like-object),它指定了用于替換 `+` 和 `/` 的字符。 如果 *s* 被不正確地填寫,一個 [`binascii.Error`](binascii.xhtml#binascii.Error "binascii.Error") 錯誤將被拋出。 如果 *validate* 值為 `False` (默認情況),則在填充檢查前,將丟棄既不在標準 base-64 字母表之中也不在備用字母表中的字符。如果 *validate* 為 `True`,這些非 base64 字符將導致 [`binascii.Error`](binascii.xhtml#binascii.Error "binascii.Error")。 `base64.``standard_b64encode`(*s*)編碼 [bytes-like object](../glossary.xhtml#term-bytes-like-object) *s*,使用標準 Base64 字母表并返回編碼過的 [`bytes`](stdtypes.xhtml#bytes "bytes")。 `base64.``standard_b64decode`(*s*)解碼 [bytes-like object](../glossary.xhtml#term-bytes-like-object) 或 ASCII 字符串 *s*,使用標準 Base64 字母表并返回編碼過的 [`bytes`](stdtypes.xhtml#bytes "bytes")。 `base64.``urlsafe_b64encode`(*s*)編碼 [bytes-like object](../glossary.xhtml#term-bytes-like-object) *s*,使用 URL 與文件系統安全的字母表,使用 `-` 以及 `_` 代替標準 Base64 字母表中的 `+` 和 `/`。返回編碼過的 [`bytes`](stdtypes.xhtml#bytes "bytes")。結果中可能包含 `=`。 `base64.``urlsafe_b64decode`(*s*)解碼 [bytes-like object](../glossary.xhtml#term-bytes-like-object) 或 ASCII 字符串 *s*,使用 URL 與文件系統安全的字母表,使用 `-` 以及 `_` 代替標準 Base64 字母表中的 `+` 和 `/`。返回解碼過的 [`bytes`](stdtypes.xhtml#bytes "bytes") `base64.``b32encode`(*s*)用 Base32 編碼 [bytes-like object](../glossary.xhtml#term-bytes-like-object) *s* 并返回編碼過的 [`bytes`](stdtypes.xhtml#bytes "bytes") `base64.``b32decode`(*s*, *casefold=False*, *map01=None*)解碼 Base32 編碼過的 [bytes-like object](../glossary.xhtml#term-bytes-like-object) 或 ASCII 字符串 *s* 并返回解碼過的 [`bytes`](stdtypes.xhtml#bytes "bytes")。 可選的 *casefold* 是一個指定小寫字幕是否可接受為輸入的標志。為了安全考慮,默認值為 `False`。 [**RFC 3548**](https://tools.ietf.org/html/rfc3548.html) \[https://tools.ietf.org/html/rfc3548.html\] 允許將字母 0(zero) 映射為字母 O(oh),并可以選擇是否將字母 1(one) 映射為 I(eye) 或 L(el)。可選參數 *map01* 不是 `None` 時,它的值指定 1 的映射目標 (I 或 l),當 *map01* 非 `None` 時, 0 總是被映射為 O。為了安全考慮,默認值被設為 `None`,如果是這樣, 0 和 1 不允許被作為輸入。 如果 *s* 被錯誤地填寫或輸入中存在字母表之外的字符,將拋出 [`binascii.Error`](binascii.xhtml#binascii.Error "binascii.Error")。 `base64.``b16encode`(*s*)用 Base16 編碼 [bytes-like object](../glossary.xhtml#term-bytes-like-object) *s* 并返回編碼過的 [`bytes`](stdtypes.xhtml#bytes "bytes") `base64.``b16decode`(*s*, *casefold=False*)解碼 Base16 編碼過的 [bytes-like object](../glossary.xhtml#term-bytes-like-object) 或 ASCII 字符串 *s* 并返回解碼過的 [`bytes`](stdtypes.xhtml#bytes "bytes")。 可選的 *casefold* 是一個指定小寫字幕是否可接受為輸入的標志。為了安全考慮,默認值為 `False`。 如果 *s* 被錯誤地填寫或輸入中存在字母表之外的字符,將拋出 [`binascii.Error`](binascii.xhtml#binascii.Error "binascii.Error")。 `base64.``a85encode`(*b*, *\**, *foldspaces=False*, *wrapcol=0*, *pad=False*, *adobe=False*)用 Ascii85 編碼 [bytes-like object](../glossary.xhtml#term-bytes-like-object) *s* 并返回編碼過的 [`bytes`](stdtypes.xhtml#bytes "bytes") *foldspaces* 是一個可選的標志,使用特殊的短序列 'y' 代替 'btoa' 提供的 4 個連續空格 (ASCII 0x20)。這個特性不被 "標準" Ascii85 編碼支持。 *wrapcol* 控制了輸出是否包含換行符 (`b'\n'`). 如果該值非零, 則每一行只有該值所限制的字符長度. *pad* 控制在編碼之前輸入是否填充為4的倍數。請注意,`btoa` 實現總是填充。 *adobe* controls whether the encoded byte sequence is framed with `<~`and `~>`, which is used by the Adobe implementation. 3\.4 新版功能. `base64.``a85decode`(*b*, *\**, *foldspaces=False*, *adobe=False*, *ignorechars=b' \\t\\n\\r\\v'*)解碼 Ascii85 編碼過的 [bytes-like object](../glossary.xhtml#term-bytes-like-object) 或 ASCII 字符串 *s* 并返回解碼過的 [`bytes`](stdtypes.xhtml#bytes "bytes")。 *foldspaces* is a flag that specifies whether the 'y' short sequence should be accepted as shorthand for 4 consecutive spaces (ASCII 0x20). This feature is not supported by the "standard" Ascii85 encoding. *adobe* controls whether the input sequence is in Adobe Ascii85 format (i.e. is framed with <~ and ~>). *ignorechars* should be a [bytes-like object](../glossary.xhtml#term-bytes-like-object) or ASCII string containing characters to ignore from the input. This should only contain whitespace characters, and by default contains all whitespace characters in ASCII. 3\.4 新版功能. `base64.``b85encode`(*b*, *pad=False*)Encode the [bytes-like object](../glossary.xhtml#term-bytes-like-object) *b* using base85 (as used in e.g. git-style binary diffs) and return the encoded [`bytes`](stdtypes.xhtml#bytes "bytes"). If *pad* is true, the input is padded with `b'\0'` so its length is a multiple of 4 bytes before encoding. 3\.4 新版功能. `base64.``b85decode`(*b*)Decode the base85-encoded [bytes-like object](../glossary.xhtml#term-bytes-like-object) or ASCII string *b* and return the decoded [`bytes`](stdtypes.xhtml#bytes "bytes"). Padding is implicitly removed, if necessary. 3\.4 新版功能. The legacy interface: `base64.``decode`(*input*, *output*)Decode the contents of the binary *input* file and write the resulting binary data to the *output* file. *input* and *output* must be [file objects](../glossary.xhtml#term-file-object). *input* will be read until `input.readline()` returns an empty bytes object. `base64.``decodebytes`(*s*)Decode the [bytes-like object](../glossary.xhtml#term-bytes-like-object) *s*, which must contain one or more lines of base64 encoded data, and return the decoded [`bytes`](stdtypes.xhtml#bytes "bytes"). 3\.1 新版功能. `base64.``decodestring`(*s*)Deprecated alias of [`decodebytes()`](#base64.decodebytes "base64.decodebytes"). 3\.1 版后已移除. `base64.``encode`(*input*, *output*)Encode the contents of the binary *input* file and write the resulting base64 encoded data to the *output* file. *input* and *output* must be [file objects](../glossary.xhtml#term-file-object). *input* will be read until `input.read()` returns an empty bytes object. [`encode()`](#base64.encode "base64.encode") inserts a newline character (`b'\n'`) after every 76 bytes of the output, as well as ensuring that the output always ends with a newline, as per [**RFC 2045**](https://tools.ietf.org/html/rfc2045.html) \[https://tools.ietf.org/html/rfc2045.html\] (MIME). `base64.``encodebytes`(*s*)Encode the [bytes-like object](../glossary.xhtml#term-bytes-like-object) *s*, which can contain arbitrary binary data, and return [`bytes`](stdtypes.xhtml#bytes "bytes") containing the base64-encoded data, with newlines (`b'\n'`) inserted after every 76 bytes of output, and ensuring that there is a trailing newline, as per [**RFC 2045**](https://tools.ietf.org/html/rfc2045.html) \[https://tools.ietf.org/html/rfc2045.html\] (MIME). 3\.1 新版功能. `base64.``encodestring`(*s*)Deprecated alias of [`encodebytes()`](#base64.encodebytes "base64.encodebytes"). 3\.1 版后已移除. An example usage of the module: ``` >>> import base64 >>> encoded = base64.b64encode(b'data to be encoded') >>> encoded b'ZGF0YSB0byBiZSBlbmNvZGVk' >>> data = base64.b64decode(encoded) >>> data b'data to be encoded' ``` 參見 模塊 [`binascii`](binascii.xhtml#module-binascii "binascii: Tools for converting between binary and various ASCII-encoded binary representations.")支持模塊,包含ASCII到二進制和二進制到ASCII轉換。 [**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 BodiesSection 5.2, "Base64 Content-Transfer-Encoding," provides the definition of the base64 encoding. ### 導航 - [索引](../genindex.xhtml "總目錄") - [模塊](../py-modindex.xhtml "Python 模塊索引") | - [下一頁](binhex.xhtml "binhex --- 對binhex4文件進行編碼和解碼") | - [上一頁](mimetypes.xhtml "mimetypes --- Map filenames to MIME types") | - ![](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 創建。
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看