久久久久久久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 函數(shù)定義中是什么意思?

        What does -gt; mean in Python function definitions?(什么-gt;在 Python 函數(shù)定義中是什么意思?)
        <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 函數(shù)定義中是什么意思?的處理方法,對(duì)大家解決問題具有一定的參考價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)吧!

                  問題描述

                  我最近在查看 Python 3.3 語法規(guī)范時(shí)發(fā)現(xiàn)了一些有趣的東西:

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

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

                  Python 2 中沒有可選的箭頭"塊,我在 Python 3 中找不到任何有關(guān)其含義的信息.事實(shí)證明這是正確的 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
                  

                  我認(rèn)為這可能是某種前置條件語法,但是:

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

                  • 我無法在此處測(cè)試 x,因?yàn)樗匀晃炊x,
                  • 無論我在箭頭后面放什么(例如2 < 1),它都不會(huì)影響函數(shù)的行為.
                  • 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.

                  熟悉這種語法風(fēng)格的人能解釋一下嗎?

                  Could anyone familiar with this syntax style explain it?

                  推薦答案

                  這是一個(gè)函數(shù)注釋.

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

                  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 建議了幾個(gè).一種非常方便的方法是允許您使用預(yù)期類型注釋參數(shù);然后很容易編寫一個(gè)裝飾器來驗(yàn)證注釋或?qū)?shù)強(qiáng)制為正確的類型.另一個(gè)是允許特定參數(shù)的文檔,而不是將其編碼到文檔字符串中.

                  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.

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

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

                  相關(guān)文檔推薦

                  python: Two modules and classes with the same name under different packages(python:不同包下同名的兩個(gè)模塊和類)
                  Configuring Python to use additional locations for site-packages(配置 Python 以使用站點(diǎn)包的其他位置)
                  How to structure python packages without repeating top level name for import(如何在不重復(fù)導(dǎo)入頂級(jí)名稱的情況下構(gòu)造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(分發(fā)帶有已編譯動(dòng)態(tài)共享庫的 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>
                            主站蜘蛛池模板: 久久国产精品亚洲 | 免费观看羞羞视频网站 | 成人网址在线观看 | 99国产精品一区二区三区 | 亚洲欧美综合精品久久成人 | 日韩色视频| 久久成人精品一区二区三区 | 就操在线| 91精品国产91久久综合桃花 | 日韩欧美在线免费观看 | 人人操日日干 | 免费观看成人性生生活片 | 国产精品亚洲一区二区三区在线 | 日本黄色一级片视频 | av看片网站 | 99久久婷婷国产综合精品电影 | 青草青草久热精品视频在线观看 | 久久久久99| 成年免费视频 | 成人av看片| 欧美三区 | 亚洲精品国产第一综合99久久 | 欧美亚洲高清 | 久久99精品久久久久久 | 日韩成人在线电影 | 一区二区视频在线 | 91精品国产综合久久香蕉麻豆 | 国产91在线 | 欧美 | 久热久热 | 日韩中文字幕一区二区三区 | 久久精品欧美一区二区三区麻豆 | 久久爱一区 | aaaaa毛片| 日本不卡一区 | 一区欧美| 国产激情精品视频 | 国产aa | 中国av在线免费观看 | 美女久久 | 国产欧美一区二区三区在线看蜜臀 | 精品国产乱码久久久久久闺蜜 |