<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>

                ThinkChat2.0新版上線,更智能更精彩,支持會話、畫圖、視頻、閱讀、搜索等,送10W Token,即刻開啟你的AI之旅 廣告
                > 類 ![](https://box.kancloud.cn/29d472aff3b668800065e8baacad29b6_526x231.png) * `c1.py `文件 ``` class Student(): name = "" age = 24 def getInfo(self): print("name "+self.name) print("age "+str(self.age)) stud1 = Student() stud2 = Student() stud3 = Student() # stud1.getInfo() print(id(stud1)) # 2825425418392 print(id(stud2)) # 2825425418560 print(id(stud3)) # 2825425418728 ``` * `c2.py `文件,類的調用 ``` from c1 import Student stru = Student() print(stru) # <c1.Student object at 0x000002703928CF60> ``` > 構造函數 * `c3.py `文件 ``` class Student(): def __init__(self): print("init") ``` * 打印構造函數 ``` stru = Student() a = stru.__init__() print(a) # None print(type(a)) # <class 'NoneType'> ``` * 返回值,只能返回 `return None`,不能返回其他 ``` def __init__(self): return None ``` * 類變量和實例變量 ``` s1 = Student("Tinywan",24) s2 = Student("TinyAiAI",22) print(s1.name) print(s2.name) print(Student.name) ``` * 類和實例的字典`__dict__` ``` s1 = Student("Tinywan",24) print(s1.__dict__) # 保存當前對象所有的變量和方法 ``` * 訪問類屬性的兩種方法 ``` class Student(): age = 24 sum = 100 def __init__(self,name,age): self.__class__.sum += 1 # 操作 print(self.__class__.sum) # 第一種 print(self.age) # 第二種 ```
                  <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>

                              哎呀哎呀视频在线观看