<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>

                企業??AI智能體構建引擎,智能編排和調試,一鍵部署,支持知識庫和私有化部署方案 廣告
                ### 導航 - [索引](../genindex.xhtml "總目錄") - [模塊](../py-modindex.xhtml "Python 模塊索引") | - [下一頁](quopri.xhtml "quopri --- Encode and decode MIME quoted-printable data") | - [上一頁](binhex.xhtml "binhex --- 對binhex4文件進行編碼和解碼") | - ![](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); | # [`binascii`](#module-binascii "binascii: Tools for converting between binary and various ASCII-encoded binary representations.") --- 二進制和 ASCII 碼互轉 - - - - - - [`binascii`](#module-binascii "binascii: Tools for converting between binary and various ASCII-encoded binary representations.") 模塊包含很多在二進制和二進制表示的各種ASCII碼之間轉換的方法。 通常情況不會直接使用這些函數,而是使用像 [`uu`](uu.xhtml#module-uu "uu: Encode and decode files in uuencode format.") , [`base64`](base64.xhtml#module-base64 "base64: RFC 3548: Base16, Base32, Base64 Data Encodings; Base85 and Ascii85") ,或 [`binhex`](binhex.xhtml#module-binhex "binhex: Encode and decode files in binhex4 format.") 這樣的封裝模塊。 為了執行效率高,[`binascii`](#module-binascii "binascii: Tools for converting between binary and various ASCII-encoded binary representations.") 模塊含有許多用 C 寫的低級函數,這些底層函數被一些高級模塊所使用。 注解 `a2b_*` 函數接受只含有 ASCII 碼的Unicode 字符串。其他函數只接受 [字節類對象](../glossary.xhtml#term-bytes-like-object) (例如 [`bytes`](stdtypes.xhtml#bytes "bytes"),[`bytearray`](stdtypes.xhtml#bytearray "bytearray") 和其他支持緩沖區協議的對象)。 在 3.3 版更改: ASCII-only unicode strings are now accepted by the `a2b_*` functions. [`binascii`](#module-binascii "binascii: Tools for converting between binary and various ASCII-encoded binary representations.") 模塊定義了以下函數: `binascii.``a2b_uu`(*string*)將單行 uu 編碼數據轉換成二進制數據并返回。uu 編碼每行的數據通常包含45 個(二進制)字節,最后一行除外。每行數據后面可能跟有空格。 `binascii.``b2a_uu`(*data*, *\**, *backtick=False*)將二進制數據轉換為 ASCII 編碼字符,返回值是轉換后的行數據,包括換行符。 *data* 的長度最多為45。如果 *backtick* 為ture,則零由 `'`'` 而不是空格表示。 在 3.7 版更改: 增加 *backtick* 形參。 `binascii.``a2b_base64`(*string*)將 base64 數據塊轉換成二進制并以二進制數據形式返回。一次可以傳遞多行數據。 `binascii.``b2a_base64`(*data*, *\**, *newline=True*)將二進制數據轉換為一行用 base64 編碼的ASCII字符串。返回值是轉換后的行數據,如果 *newline* 為true,則返回值包括換行符。該函數的輸出符合:rfc:3548。 在 3.6 版更改: 增加 *newline* 形參。 `binascii.``a2b_qp`(*data*, *header=False*)將一個引號可打印的數據塊轉換成二進制數據并返回。一次可以轉換多行。如果可選參數 *header* 存在且為true,則數據中的下劃線將被解碼成空格。 `binascii.``b2a_qp`(*data*, *quotetabs=False*, *istext=True*, *header=False*)將二進制數據轉換為一行或多行帶引號可打印編碼的ASCII字符串。返回值是轉換后的行數據。如果可選參數 *quotetabs* 存在且為真值,則對所有制表符和空格進行編碼。如果可選參數 *istext* 存在且為真值,則不對新行進行編碼,但將對尾隨空格進行編碼。如果可選參數 *header* 存在且為true,則空格將被編碼為下劃線 [**RFC 1522**](https://tools.ietf.org/html/rfc1522.html) \[https://tools.ietf.org/html/rfc1522.html\]。如果可選參數 *header* 存在且為假值,則也會對換行符進行編碼;不進行換行轉換編碼可能會破壞二進制數據流。 `binascii.``a2b_hqx`(*string*)將 binhex4 格式的 ASCII 數據不進行 RLE 解壓縮直接轉換為二進制數據。該字符串應包含完整數量的二進制字節,或者(在binhex4 數據最后部分)剩余位為零。 `binascii.``rledecode_hqx`(*data*)根據 binhex4 標準對數據執行 RLE 解壓縮。該算法在一個字節的數據后使用 `0x90` 作為重復指示符,然后計數。計數 `0` 指定字節值 `0x90` 。該例程返回解壓縮的數據,輸入數據以孤立的重復指示符結束的情況下,將引發 [`Incomplete`](#binascii.Incomplete "binascii.Incomplete") 異常。 在 3.2 版更改: 僅接受 bytestring 或 bytearray 對象作為輸入。 `binascii.``rlecode_hqx`(*data*)在 *data* 上執行 binhex4 游程編碼壓縮并返回結果。 `binascii.``b2a_hqx`(*data*)執行 hexbin4 類型二進制到 ASCII 碼的轉換并返回結果字符串。輸入數據應經過 RLE 編碼,且數據長度可被3整除(除了最后一個片段)。 `binascii.``crc_hqx`(*data*, *value*)以 *value* 作為初始 CRC 計算 *data* 的16位 CRC 值,返回其結果。這里使用 CRC-CCITT 生成多項式 *x*16 + *x*12 + *x*5 + 1 ,通常表示為0x1021。該 CRC 被用于 binhex4 格式。 `binascii.``crc32`(*data*\[, *value*\])計算 CRC-32 ,從 *value* 的初始 CRC 開始計算 *data* 的32位校驗和。默認初始 CRC 為零。該算法與 ZIP 文件校驗和一致。由于該算法被設計用作校驗和算法,因此不適合用作通用散列算法。使用方法如下: ``` print(binascii.crc32(b"hello world")) # Or, in two pieces: crc = binascii.crc32(b"hello") crc = binascii.crc32(b" world", crc) print('crc32 = {:#010x}'.format(crc)) ``` 在 3.0 版更改: 校驗結果始終是無符號類型的。要在所有Python版本和平臺上生成相同的數值,請使用 `crc32(data) & 0xffffffff` 。 `binascii.``b2a_hex`(*data*)`binascii.``hexlify`(*data*)返回二進制數據 *data* 的十六進制表示形式。 *data* 的每個字節都被轉換為相應的2位十六進制表示形式。因此返回的字節對象的長度是 *data* 的兩倍。 使用:[`bytes.hex()`](stdtypes.xhtml#bytes.hex "bytes.hex") 方法也可以方便地實現相似的功能(但僅返回文本字符串)。 `binascii.``a2b_hex`(*hexstr*)`binascii.``unhexlify`(*hexstr*)返回由十六進制字符串 *hexstr* 表示的二進制數據。此函數功能與 [`b2a_hex()`](#binascii.b2a_hex "binascii.b2a_hex") 相反。 *hexstr* 必須包含偶數個十六進制數字(可以是大寫或小寫),否則會引發 [`Error`](#binascii.Error "binascii.Error") 異常。 使用:[`bytes.fromhex()`](stdtypes.xhtml#bytes.fromhex "bytes.fromhex") 類方法也實現相似的功能(僅接受文本字符串參數,不限制其中的空白字符)。 *exception* `binascii.``Error`通常是因為編程錯誤引發的異常。 *exception* `binascii.``Incomplete`數據不完整引發的異常。通常不是編程錯誤導致的,可以通過讀取更多的數據并再次嘗試來處理該異常。 參見 模塊 [`base64`](base64.xhtml#module-base64 "base64: RFC 3548: Base16, Base32, Base64 Data Encodings; Base85 and Ascii85")支持在16,32,64,85進制中進行符合 RFC 協議的 base64 樣式編碼。 模塊 [`binhex`](binhex.xhtml#module-binhex "binhex: Encode and decode files in binhex4 format.")支持在 Macintosh 上使用的 binhex 格式。 模塊 [`uu`](uu.xhtml#module-uu "uu: Encode and decode files in uuencode format.")支持在 Unix 上使用的 UU 編碼。 模塊 [`quopri`](quopri.xhtml#module-quopri "quopri: Encode and decode files using the MIME quoted-printable encoding.")支持在 MIME 版本電子郵件中使用引號可打印編碼。 ### 導航 - [索引](../genindex.xhtml "總目錄") - [模塊](../py-modindex.xhtml "Python 模塊索引") | - [下一頁](quopri.xhtml "quopri --- Encode and decode MIME quoted-printable data") | - [上一頁](binhex.xhtml "binhex --- 對binhex4文件進行編碼和解碼") | - ![](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>

                              哎呀哎呀视频在线观看