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

                ??碼云GVP開源項目 12k star Uniapp+ElementUI 功能強大 支持多語言、二開方便! 廣告
                ### 導航 - [索引](../genindex.xhtml "總目錄") - [模塊](../py-modindex.xhtml "Python 模塊索引") | - [下一頁](grammar.xhtml "10. 完整的語法規范") | - [上一頁](compound_stmts.xhtml "8. 復合語句") | - ![](https://box.kancloud.cn/a721fc7ec672275e257bbbfde49a4d4e_16x16.png) - [Python](https://www.python.org/) ? - zh\_CN 3.7.3 [文檔](../index.xhtml) ? - [Python 語言參考](index.xhtml) ? - $('.inline-search').show(0); | # 9. 最高層級組件 Python 解釋器可以從多種源獲得輸入:作為標準輸入或程序參數傳入的腳本,以交互方式鍵入的語句,導入的模塊源文件等等。 這一章將給出在這些情況下所用的語法。 ## 9.1. 完整的 Python 程序 雖然語言規范描述不必規定如何發起調用語言解釋器,但對完整的 Python 程序加以說明還是很有用的。 一個完整的 Python 程序會在最小初始化環境中被執行:所有內置和標準模塊均為可用,但均處于未初始化狀態,只有 [`sys`](../library/sys.xhtml#module-sys "sys: Access system-specific parameters and functions.") (各種系統服務), [`builtins`](../library/builtins.xhtml#module-builtins "builtins: The module that provides the built-in namespace.") (內置函數、異常以及 `None`) 和 [`__main__`](../library/__main__.xhtml#module-__main__ "__main__: The environment where the top-level script is run.") 除外。 最后一個模塊用于為完整程序的執行提供局部和全局命名空間。 適用于一個完整 Python 程序的語法即下節所描述的文件輸入。 解釋器也可以通過交互模式被發起調用;在此情況下,它并不讀取和執行一個完整程序,而是每次讀取和執行一條語句(可能為復合語句)。 此時的初始環境與一個完整程序的相同;每條語句會在 [`__main__`](../library/__main__.xhtml#module-__main__ "__main__: The environment where the top-level script is run.") 的命名空間中被執行。 一個完整程序可通過三種形式被傳遞給解釋器:使用 [`-c`](../using/cmdline.xhtml#cmdoption-c) *字符串* 命令行選項,使用一個文件作為第一個命令行參數,或者使用標準輸入。 如果文件或標準輸入是一個 tty 設置,解釋器會進入交互模式;否則的話,它會將文件當作一個完整程序來執行。 ## 9.2. 文件輸入 所有從非交互式文件讀取的輸入都具有相同的形式: ``` file_input ::= (NEWLINE | statement)* ``` 此語法用于下列幾種情況: - 解析一個完整 Python 程序時(從文件或字符串); - 解析一個模塊時; - 解析一個傳遞給 [`exec()`](../library/functions.xhtml#exec "exec") 函數的字符串時; ## 9.3. 交互式輸入 交互模式下的輸入使用以下語法進行解析: ``` interactive_input ::= [stmt_list] NEWLINE | compound_stmt NEWLINE ``` 請注意在交互模式下一條(最高層級)復合語句必須帶有一個空行;這對于幫助解析器確定輸入的結束是必須的。 ## 9.4. 表達式輸入 [`eval()`](../library/functions.xhtml#eval "eval") 被用于表達式輸入。 它會忽略開頭的空白。 傳遞給 [`eval()`](../library/functions.xhtml#eval "eval") 的字符串參數必須具有以下形式: ``` eval_input ::= expression_list NEWLINE* ``` ### 導航 - [索引](../genindex.xhtml "總目錄") - [模塊](../py-modindex.xhtml "Python 模塊索引") | - [下一頁](grammar.xhtml "10. 完整的語法規范") | - [上一頁](compound_stmts.xhtml "8. 復合語句") | - ![](https://box.kancloud.cn/a721fc7ec672275e257bbbfde49a4d4e_16x16.png) - [Python](https://www.python.org/) ? - zh\_CN 3.7.3 [文檔](../index.xhtml) ? - [Python 語言參考](index.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>

                              哎呀哎呀视频在线观看