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

                ThinkChat2.0新版上線,更智能更精彩,支持會話、畫圖、視頻、閱讀、搜索等,送10W Token,即刻開啟你的AI之旅 廣告
                ### 導航 - [索引](../genindex.xhtml "總目錄") - [模塊](../py-modindex.xhtml "Python 模塊索引") | - [下一頁](chunk.xhtml "chunk --- Read IFF chunked data") | - [上一頁](sunau.xhtml "sunau --- 讀寫 Sun AU 文件") | - ![](https://box.kancloud.cn/a721fc7ec672275e257bbbfde49a4d4e_16x16.png) - [Python](https://www.python.org/) ? - zh\_CN 3.7.3 [文檔](../index.xhtml) ? - [Python 標準庫](index.xhtml) ? - [多媒體服務](mm.xhtml) ? - $('.inline-search').show(0); | # [`wave`](#module-wave "wave: Provide an interface to the WAV sound format.") --- 讀寫WAV格式文件 **源代碼:** [Lib/wave.py](https://github.com/python/cpython/tree/3.7/Lib/wave.py) \[https://github.com/python/cpython/tree/3.7/Lib/wave.py\] - - - - - - [`wave`](#module-wave "wave: Provide an interface to the WAV sound format.") 模塊提供了一個處理 WAV 聲音格式的便利接口。它不支持壓縮/解壓,但是支持單聲道/立體聲。 [`wave`](#module-wave "wave: Provide an interface to the WAV sound format.") 模塊定義了以下函數和異常: `wave.``open`(*file*, *mode=None*)如果 *file* 是一個字符串,打開對應文件名的文件。否則就把它作為文件類對象來處理。*mode* 可以為以下值: `'rb'`只讀模式。 `'wb'`只寫模式。 注意不支持同時讀寫WAV文件。 *mode* 設為 `'rb'` 時返回一個 `Wave_read` 對象,而 *mode* 設為 `'wb'` 時返回一個 `Wave_write` 對象。如果省略 *mode* 并指定 *file* 來傳入一個文件類對象,則 `file.mode` 會被用作 *mode* 的默認值。 如果操作的是文件對象,當使用 wave 對象的 `close()` 方法時,并不會真正關閉文件對象,這需要調用者負責來關閉文件對象。 The [`open()`](#wave.open "wave.open") function may be used in a [`with`](../reference/compound_stmts.xhtml#with) statement. When the `with` block completes, the [`Wave_read.close()`](#wave.Wave_read.close "wave.Wave_read.close") or [`Wave_write.close()`](#wave.Wave_write.close "wave.Wave_write.close") method is called. 在 3.4 版更改: 添加了對不可搜索文件的支持。 `wave.``openfp`(*file*, *mode*)同 [`open()`](#wave.open "wave.open"),用于向后兼容。 Deprecated since version 3.7, will be removed in version 3.9. *exception* `wave.``Error`當不符合WAV格式或無法操作時引發的錯誤。 ## Wave\_read對象 由 [`open()`](#wave.open "wave.open") 返回的 Wave\_read 對象,有以下幾種方法: `Wave_read.``close`()關閉 [`wave`](#module-wave "wave: Provide an interface to the WAV sound format.") 打開的數據流并使對象不可用。當對象銷毀時會自動調用。 `Wave_read.``getnchannels`()返回聲道數量(`1` 為單聲道,`2` 為立體聲) `Wave_read.``getsampwidth`()返回采樣字節長度。 `Wave_read.``getframerate`()返回采樣頻率。 `Wave_read.``getnframes`()返回音頻總幀數。 `Wave_read.``getcomptype`()返回壓縮類型(只支持 `'NONE'` 類型) `Wave_read.``getcompname`()[`getcomptype()`](#wave.Wave_read.getcomptype "wave.Wave_read.getcomptype") 的通俗版本。使用 `'not compressed'` 代替 `'NONE'`。 `Wave_read.``getparams`()返回一個 [`namedtuple()`](collections.xhtml#collections.namedtuple "collections.namedtuple")`(nchannels, sampwidth, framerate, nframes, comptype, compname)`,與 `get*()` 方法的輸出相同。 `Wave_read.``readframes`(*n*)讀取并返回以 [`bytes`](stdtypes.xhtml#bytes "bytes") 對象表示的最多 *n* 幀音頻。 `Wave_read.``rewind`()設置當前文件指針位置。 后面兩個方法是為了和 [`aifc`](aifc.xhtml#module-aifc "aifc: Read and write audio files in AIFF or AIFC format.") 保持兼容,實際不做任何事情。 `Wave_read.``getmarkers`()返回 `None`。 `Wave_read.``getmark`(*id*)引發錯誤異常。 以下兩個方法都使用指針,具體實現由其底層決定。 `Wave_read.``setpos`(*pos*)設置文件指針到指定位置。 `Wave_read.``tell`()返回當前文件指針位置。 ## Wave\_write 對象 For seekable output streams, the `wave` header will automatically be updated to reflect the number of frames actually written. For unseekable streams, the *nframes* value must be accurate when the first frame data is written. An accurate *nframes* value can be achieved either by calling [`setnframes()`](#wave.Wave_write.setnframes "wave.Wave_write.setnframes") or [`setparams()`](#wave.Wave_write.setparams "wave.Wave_write.setparams") with the number of frames that will be written before [`close()`](#wave.Wave_write.close "wave.Wave_write.close") is called and then using [`writeframesraw()`](#wave.Wave_write.writeframesraw "wave.Wave_write.writeframesraw") to write the frame data, or by calling [`writeframes()`](#wave.Wave_write.writeframes "wave.Wave_write.writeframes") with all of the frame data to be written. In the latter case [`writeframes()`](#wave.Wave_write.writeframes "wave.Wave_write.writeframes") will calculate the number of frames in the data and set *nframes* accordingly before writing the frame data. 由 [`open()`](#wave.open "wave.open") 返回的 Wave\_write 對象,有以下幾種方法: 在 3.4 版更改: 添加了對不可搜索文件的支持。 `Wave_write.``close`()Make sure *nframes* is correct, and close the file if it was opened by [`wave`](#module-wave "wave: Provide an interface to the WAV sound format."). This method is called upon object collection. It will raise an exception if the output stream is not seekable and *nframes* does not match the number of frames actually written. `Wave_write.``setnchannels`(*n*)設置聲道數。 `Wave_write.``setsampwidth`(*n*)設置采樣字節長度為 *n*。 `Wave_write.``setframerate`(*n*)設置采樣頻率為 *n*。 在 3.2 版更改: A non-integral input to this method is rounded to the nearest integer. `Wave_write.``setnframes`(*n*)Set the number of frames to *n*. This will be changed later if the number of frames actually written is different (this update attempt will raise an error if the output stream is not seekable). `Wave_write.``setcomptype`(*type*, *name*)設置壓縮格式。目前只支持 `NONE` 即無壓縮格式。 `Wave_write.``setparams`(*tuple*)*tuple* 應該是 `(nchannels, sampwidth, framerate, nframes, comptype, compname)`,每項的值應可用于 `set*()` 方法。設置所有形參。 `Wave_write.``tell`()返回當前文件指針,其指針含義和 [`Wave_read.tell()`](#wave.Wave_read.tell "wave.Wave_read.tell") 以及 [`Wave_read.setpos()`](#wave.Wave_read.setpos "wave.Wave_read.setpos") 是一致的。 `Wave_write.``writeframesraw`(*data*)寫入音頻數據但不更新 *nframes*。 在 3.4 版更改: Any [bytes-like object](../glossary.xhtml#term-bytes-like-object) is now accepted. `Wave_write.``writeframes`(*data*)Write audio frames and make sure *nframes* is correct. It will raise an error if the output stream is not seekable and the total number of frames that have been written after *data* has been written does not match the previously set value for *nframes*. 在 3.4 版更改: Any [bytes-like object](../glossary.xhtml#term-bytes-like-object) is now accepted. 注意在調用 `writeframes()` 或 `writeframesraw()` 之后再設置任何格式參數是無效的,而且任何這樣的嘗試將引發 [`wave.Error`](#wave.Error "wave.Error")。 ### 導航 - [索引](../genindex.xhtml "總目錄") - [模塊](../py-modindex.xhtml "Python 模塊索引") | - [下一頁](chunk.xhtml "chunk --- Read IFF chunked data") | - [上一頁](sunau.xhtml "sunau --- 讀寫 Sun AU 文件") | - ![](https://box.kancloud.cn/a721fc7ec672275e257bbbfde49a4d4e_16x16.png) - [Python](https://www.python.org/) ? - zh\_CN 3.7.3 [文檔](../index.xhtml) ? - [Python 標準庫](index.xhtml) ? - [多媒體服務](mm.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>

                              哎呀哎呀视频在线观看