<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國際加速解決方案。 廣告
                這些類可以用作未定義類型。?[Environment](http://docs.jinkan.org/docs/jinja2/api.html#jinja2.Environment "jinja2.Environment")?的構造函數接受一個可以是 那些類或一個[Undefined](http://docs.jinkan.org/docs/jinja2/api.html#jinja2.Undefined "jinja2.Undefined")?的自定義子類的?undefined?參數。無論何時, 這些對象創建或返回時,模板引擎都不能查出其名稱或訪問其屬性。未定義值上的 某些操作之后是允許的,而其它的會失敗。 最接近常規 Python 行為的是?StrictUndefined?,如果它是一個未定義對象, 它不允許除了測試之外的一切操作。 *class?*jinja2.Undefined[](http://docs.jinkan.org/docs/jinja2/api.html#jinja2.Undefined "Permalink to this definition") The default undefined type. This undefined type can be printed and iterated over, but every other access will raise an?[UndefinedError](http://docs.jinkan.org/docs/jinja2/api.html#jinja2.UndefinedError "jinja2.UndefinedError"): ~~~ >>> foo = Undefined(name='foo') >>> str(foo) '' >>> not foo True >>> foo + 42 Traceback (most recent call last): ... UndefinedError: 'foo' is undefined ~~~ _undefined_hint[](http://docs.jinkan.org/docs/jinja2/api.html#jinja2.Undefined._undefined_hint "Permalink to this definition") None?或給未定義對象的錯誤消息 unicode 字符串。 _undefined_obj[](http://docs.jinkan.org/docs/jinja2/api.html#jinja2.Undefined._undefined_obj "Permalink to this definition") None?或引起未定義對象創建的對象(例如一個屬性不存在)。 _undefined_name[](http://docs.jinkan.org/docs/jinja2/api.html#jinja2.Undefined._undefined_name "Permalink to this definition") 未定義變量/屬性的名稱,如果沒有此類信息,留為?None?。 _undefined_exception[](http://docs.jinkan.org/docs/jinja2/api.html#jinja2.Undefined._undefined_exception "Permalink to this definition") 未定義對象想要拋出的異常。這通常是?[UndefinedError](http://docs.jinkan.org/docs/jinja2/api.html#jinja2.UndefinedError "jinja2.UndefinedError")?或?SecurityError?之一。 _fail_with_undefined_error(**args*,?***kwargs*)[](http://docs.jinkan.org/docs/jinja2/api.html#jinja2.Undefined._fail_with_undefined_error "Permalink to this definition") 參數任意,調用這個方法時會拋出帶有由未定義對象上存儲的未定義 hint 生成的錯誤信息的?[_undefined_exception](http://docs.jinkan.org/docs/jinja2/api.html#jinja2.Undefined._undefined_exception "jinja2.Undefined._undefined_exception")?異常。 *class?*jinja2.DebugUndefined[](http://docs.jinkan.org/docs/jinja2/api.html#jinja2.DebugUndefined "Permalink to this definition") An undefined that returns the debug info when printed. ~~~ >>> foo = DebugUndefined(name='foo') >>> str(foo) '{{ foo }}' >>> not foo True >>> foo + 42 Traceback (most recent call last): ... UndefinedError: 'foo' is undefined ~~~ *class?*jinja2.StrictUndefined[](http://docs.jinkan.org/docs/jinja2/api.html#jinja2.StrictUndefined "Permalink to this definition") An undefined that barks on print and iteration as well as boolean tests and all kinds of comparisons. In other words: you can do nothing with it except checking if it’s defined using the?defined?test. ~~~ >>> foo = StrictUndefined(name='foo') >>> str(foo) Traceback (most recent call last): ... UndefinedError: 'foo' is undefined >>> not foo Traceback (most recent call last): ... UndefinedError: 'foo' is undefined >>> foo + 42 Traceback (most recent call last): ... UndefinedError: 'foo' is undefined ~~~ 未定義對象由調用?[undefined](http://docs.jinkan.org/docs/jinja2/templates.html#undefined "undefined")?創建。 實現 [Undefined](http://docs.jinkan.org/docs/jinja2/api.html#jinja2.Undefined "jinja2.Undefined")?對象通過重載特殊的?__underscore__?方法實現。例如 默認的?[Undefined](http://docs.jinkan.org/docs/jinja2/api.html#jinja2.Undefined "jinja2.Undefined")?類實現?__unicode__?為返回一個空字符串,但?__int__?和其它會始終拋出異常。你可以自己通過返回?0?實現轉換為 int: ~~~ class NullUndefined(Undefined): def __int__(self): return 0 def __float__(self): return 0.0 ~~~ 要禁用一個方法,重載它并拋出?[_undefined_exception](http://docs.jinkan.org/docs/jinja2/api.html#jinja2.Undefined._undefined_exception "jinja2.Undefined._undefined_exception")?。因 為這在未定義對象中非常常用,未定義對象有輔助方法?[_fail_with_undefined_error()](http://docs.jinkan.org/docs/jinja2/api.html#jinja2.Undefined._fail_with_undefined_error "jinja2.Undefined._fail_with_undefined_error")?自動拋出錯誤。這里的一個類 工作類似正規的?[Undefined](http://docs.jinkan.org/docs/jinja2/api.html#jinja2.Undefined "jinja2.Undefined")?,但它在迭代時阻塞: > > > class NonIterableUndefined(Undefined): > > __iter__ = Undefined._fail_with_undefined_error > >
                  <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>

                              哎呀哎呀视频在线观看