久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

<tfoot id='GrqmE'></tfoot>
<i id='GrqmE'><tr id='GrqmE'><dt id='GrqmE'><q id='GrqmE'><span id='GrqmE'><b id='GrqmE'><form id='GrqmE'><ins id='GrqmE'></ins><ul id='GrqmE'></ul><sub id='GrqmE'></sub></form><legend id='GrqmE'></legend><bdo id='GrqmE'><pre id='GrqmE'><center id='GrqmE'></center></pre></bdo></b><th id='GrqmE'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='GrqmE'><tfoot id='GrqmE'></tfoot><dl id='GrqmE'><fieldset id='GrqmE'></fieldset></dl></div>

      1. <small id='GrqmE'></small><noframes id='GrqmE'>

        <legend id='GrqmE'><style id='GrqmE'><dir id='GrqmE'><q id='GrqmE'></q></dir></style></legend>
          <bdo id='GrqmE'></bdo><ul id='GrqmE'></ul>

      2. 什么-&gt;在 Python 函數定義中是什么意思?

        What does -gt; mean in Python function definitions?(什么-gt;在 Python 函數定義中是什么意思?)
        <i id='4JqcF'><tr id='4JqcF'><dt id='4JqcF'><q id='4JqcF'><span id='4JqcF'><b id='4JqcF'><form id='4JqcF'><ins id='4JqcF'></ins><ul id='4JqcF'></ul><sub id='4JqcF'></sub></form><legend id='4JqcF'></legend><bdo id='4JqcF'><pre id='4JqcF'><center id='4JqcF'></center></pre></bdo></b><th id='4JqcF'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='4JqcF'><tfoot id='4JqcF'></tfoot><dl id='4JqcF'><fieldset id='4JqcF'></fieldset></dl></div>
        • <small id='4JqcF'></small><noframes id='4JqcF'>

            <bdo id='4JqcF'></bdo><ul id='4JqcF'></ul>

              <tbody id='4JqcF'></tbody>

                <legend id='4JqcF'><style id='4JqcF'><dir id='4JqcF'><q id='4JqcF'></q></dir></style></legend>
                • <tfoot id='4JqcF'></tfoot>
                  本文介紹了什么-&gt;在 Python 函數定義中是什么意思?的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

                  問題描述

                  我最近在查看 Python 3.3 語法規范時發現了一些有趣的東西:

                  I've recently noticed something interesting when looking at Python 3.3 grammar specification:

                  funcdef: 'def' NAME parameters ['->' test] ':' suite
                  

                  Python 2 中沒有可選的箭頭"塊,我在 Python 3 中找不到任何有關其含義的信息.事實證明這是正確的 Python,并且被解釋器接受:

                  The optional 'arrow' block was absent in Python 2 and I couldn't find any information regarding its meaning in Python 3. It turns out this is correct Python and it's accepted by the interpreter:

                  def f(x) -> 123:
                      return x
                  

                  我認為這可能是某種前置條件語法,但是:

                  I thought that this might be some kind of a precondition syntax, but:

                  • 我無法在此處測試 x,因為它仍然未定義,
                  • 無論我在箭頭后面放什么(例如2 < 1),它都不會影響函數的行為.
                  • I cannot test x here, as it is still undefined,
                  • No matter what I put after the arrow (e.g. 2 < 1), it doesn't affect the function behavior.

                  熟悉這種語法風格的人能解釋一下嗎?

                  Could anyone familiar with this syntax style explain it?

                  推薦答案

                  這是一個函數注釋.

                  更詳細地說,Python 2.x 有文檔字符串,允許您將元數據字符串附加到各種類型的對象.這非常方便,因此 Python 3 通過允許您將元數據附加到描述其參數和返回值的函數來擴展該功能.

                  In more detail, Python 2.x has docstrings, which allow you to attach a metadata string to various types of object. This is amazingly handy, so Python 3 extends the feature by allowing you to attach metadata to functions describing their parameters and return values.

                  沒有先入為主的用例,但 PEP 建議了幾個.一種非常方便的方法是允許您使用預期類型注釋參數;然后很容易編寫一個裝飾器來驗證注釋或將參數強制為正確的類型.另一個是允許特定參數的文檔,而不是將其編碼到文檔字符串中.

                  There's no preconceived use case, but the PEP suggests several. One very handy one is to allow you to annotate parameters with their expected types; it would then be easy to write a decorator that verifies the annotations or coerces the arguments to the right type. Another is to allow parameter-specific documentation instead of encoding it into the docstring.

                  這篇關于什么-&gt;在 Python 函數定義中是什么意思?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

                  【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

                  相關文檔推薦

                  python: Two modules and classes with the same name under different packages(python:不同包下同名的兩個模塊和類)
                  Configuring Python to use additional locations for site-packages(配置 Python 以使用站點包的其他位置)
                  How to structure python packages without repeating top level name for import(如何在不重復導入頂級名稱的情況下構造python包)
                  Install python packages on OpenShift(在 OpenShift 上安裝 python 包)
                  How to refresh sys.path?(如何刷新 sys.path?)
                  Distribute a Python package with a compiled dynamic shared library(分發帶有已編譯動態共享庫的 Python 包)

                  <small id='VSzSC'></small><noframes id='VSzSC'>

                  <tfoot id='VSzSC'></tfoot>

                      <tbody id='VSzSC'></tbody>

                        <bdo id='VSzSC'></bdo><ul id='VSzSC'></ul>
                          <i id='VSzSC'><tr id='VSzSC'><dt id='VSzSC'><q id='VSzSC'><span id='VSzSC'><b id='VSzSC'><form id='VSzSC'><ins id='VSzSC'></ins><ul id='VSzSC'></ul><sub id='VSzSC'></sub></form><legend id='VSzSC'></legend><bdo id='VSzSC'><pre id='VSzSC'><center id='VSzSC'></center></pre></bdo></b><th id='VSzSC'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='VSzSC'><tfoot id='VSzSC'></tfoot><dl id='VSzSC'><fieldset id='VSzSC'></fieldset></dl></div>
                        1. <legend id='VSzSC'><style id='VSzSC'><dir id='VSzSC'><q id='VSzSC'></q></dir></style></legend>
                            主站蜘蛛池模板: 在线观看欧美日韩 | 欧美精品日韩 | 精品国产一区二区在线观看 | 午夜在线免费视频 | 青青草手机视频 | 丁香九月婷婷 | 一级毛片在线播放 | 日本不卡视频在线观看 | 97国产超碰 | 欧美香蕉视频 | 亚洲国产激情 | 天天插天天射 | 亚洲国产精品久久久久久久 | 久草中文在线 | 欧美亚洲激情 | 99热亚洲 | 91久久精品日日躁夜夜躁欧美 | 91精品国产日韩91久久久久久 | 日本黄色免费网站 | 亚洲精品一二三区 | 不卡在线视频 | 国产激情网 | 国产一级二级片 | 一区二区高清视频 | 亚洲精品久久久蜜桃 | 精品免费观看 | 欧美一区二区三区的 | 亚洲精品乱码久久久久 | 午夜高清 | 操操操av| 欧美精品久久久久久久多人混战 | 在线日韩欧美 | 男人午夜视频 | 中文字幕亚洲一区 | 全部免费毛片在线播放高潮 | 色大师av| eeuss一区二区三区 | 日韩午夜精品 | 久久在线精品 | 亚洲成人a v | 欧美激情视频网站 |