<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智能體構建引擎,智能編排和調試,一鍵部署,支持知識庫和私有化部署方案 廣告
                更新于2017年4月15日,下午 ## 概述 optparse用來解析命令行參數 #### 官方文檔 https://docs.python.org/3/library/optparse.html #### 例子 ```python from optparse import OptionParser usage = "usage: %prog [options] arg1 arg2" version="%prog 1.0" parser = OptionParser(usage=usage, version=version) parser.add_option("-f", "--file", dest="filename", action="store", type="string", default="foo.txt") parser.add_option("-v", dest="verbose", action="store_true", default=True) args = ["-f", "foo.txt"] (options, args) = parser.parse_args(args) print options.filename ``` 當 optparse 解析到-f,會繼續解析后面的foo.txt,然后將foo.txt保存到 options.filename 里。當調用 parser.args() 后,options.filename 的值就為foo.txt。 `add_option() `: 定義命令行參數 `parse_args()`: 返回的兩個值 > **options**:它是一個對象(optpars.Values),**字典形式**保存選項和參數。 > **args**:它是一個由 positional arguments 組成的列表。 #### dest > **dest**參數也是可選的。如果沒有指定 dest 參數,將用命令行的參數名來對 options 對象的值進行存取。 #### action > **action** 是 parse_args() 方法的參數之一,它指示 optparse 當解析到一個命令行參數時該如何處理。action 有一組固定的值可供選擇,默認是`store`,表示將命令行參數值保存在 options 對象里。store_true 和 store_false 表示將參數保存到**args**中,并將對應選項的值相應設置為True或者False #### type > **type** 參數默認為string,如 int 或者 float #### default > **default** 參數用于設置默認值,可以使True或者False或者其他默認參數
                  <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>

                              哎呀哎呀视频在线观看