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

<legend id='f8tTE'><style id='f8tTE'><dir id='f8tTE'><q id='f8tTE'></q></dir></style></legend>

        <bdo id='f8tTE'></bdo><ul id='f8tTE'></ul>
    1. <tfoot id='f8tTE'></tfoot>

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

      2. 如何在 Python 3.5 中鍵入提示屬性?

        How can I type hint an attribute in Python 3.5?(如何在 Python 3.5 中鍵入提示屬性?)
        <i id='1dQqh'><tr id='1dQqh'><dt id='1dQqh'><q id='1dQqh'><span id='1dQqh'><b id='1dQqh'><form id='1dQqh'><ins id='1dQqh'></ins><ul id='1dQqh'></ul><sub id='1dQqh'></sub></form><legend id='1dQqh'></legend><bdo id='1dQqh'><pre id='1dQqh'><center id='1dQqh'></center></pre></bdo></b><th id='1dQqh'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='1dQqh'><tfoot id='1dQqh'></tfoot><dl id='1dQqh'><fieldset id='1dQqh'></fieldset></dl></div>

          • <bdo id='1dQqh'></bdo><ul id='1dQqh'></ul>
            <tfoot id='1dQqh'></tfoot>

            • <legend id='1dQqh'><style id='1dQqh'><dir id='1dQqh'><q id='1dQqh'></q></dir></style></legend>
                    <tbody id='1dQqh'></tbody>

                  <small id='1dQqh'></small><noframes id='1dQqh'>

                  本文介紹了如何在 Python 3.5 中鍵入提示屬性?的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

                  問題描述

                  我有一個類,我希望屬性的初始值為 None:

                  I have a class where I want the initial value of an attribute to be None:

                  class SomeClass:
                      def __init__(self):
                          self.some_attribute = None
                  

                  如何添加類型提示,以便 IDE 了解 some_attribute 通常屬于 AnotherClass 類型?

                  How can I add type hinting, so that the IDE understands that some_attribute is usually of the type AnotherClass?

                  推薦答案

                  在 Python 3.5 中,你必須寫

                  In Python 3.5, you have to write

                  self.some_attribute = None  # type: AnotherClass
                  

                  從 Python 3.6 開始,為變量添加了新的類型提示語法(PEP 526):

                  Since Python 3.6, new type hinting syntax was added for variables (PEP 526):

                  self.some_attribute: AnotherClass = None
                  

                  這可能會讓每個類型檢查系統都抱怨,因為 None 實際上不是 AnotherClass 的實例.相反,您可以使用 typing.Union[None, AnotherClass],或簡寫:

                  This will probably make every type-checking system complain, because None is in fact not an instance of AnotherClass. Instead, you can use typing.Union[None, AnotherClass], or the shorthand:

                  from typing import Optional
                  ...
                  self.some_attribute: Optional[AnotherClass] = None
                  

                  這篇關于如何在 Python 3.5 中鍵入提示屬性?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持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 包)

                      <legend id='35VhU'><style id='35VhU'><dir id='35VhU'><q id='35VhU'></q></dir></style></legend>
                          <tbody id='35VhU'></tbody>

                          <bdo id='35VhU'></bdo><ul id='35VhU'></ul>

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

                            主站蜘蛛池模板: 国产精品久久九九 | 国产精品免费视频一区 | 日韩α片| 丝袜天堂 | 午夜天堂精品久久久久 | 美女亚洲一区 | 国产精品久久久久久久久图文区 | 日韩中文字幕在线视频 | 黄色毛片黄色毛片 | 欧美日韩国产高清 | 在线视频一区二区三区 | 日韩一区二区三区在线 | 另类二区 | 午夜精品一区二区三区在线视频 | 亚洲精品视频观看 | 亚洲一区二区三区在线视频 | 成人深夜小视频 | 久久99精品久久久97夜夜嗨 | 国产人成精品一区二区三 | 久久婷婷国产麻豆91 | 欧美性猛交一区二区三区精品 | av一区二区三区四区 | a级片网站| 国产有码| 天堂亚洲| 日韩在线 | 国产精品99久久久久久动医院 | 欧美一区二区小视频 | 中文字幕亚洲视频 | 久久国产精品久久 | 在线观看 亚洲 | 免费在线观看黄网站 | 日韩第一区 | 激情欧美一区二区三区 | 久久久久久国产 | av手机免费在线观看 | 99在线免费视频 | 国产免费福利小视频 | 国产精品伦一区二区三级视频 | 九七午夜剧场福利写真 | 国产精品久久久久久久久久久免费看 |