
Python 入門指南 5.0
exercise1602.py
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | # 定義類別 Demo3 class Demo3: # 定義類別屬性 count count = 0 # count 加一 @staticmethod def add_instance(): Demo3.count += 1 # 以下是執行部分 # 利用迴圈執行 add_add_instance() for i in range(101): Demo3.add_instance() # 印出 d 類別屬性 count print(Demo3.count) # 檔名: exercise1602.py # 說明:《Python入門指南》的練習 # 網站: http://kaiching.org # 作者: 張凱慶 # 時間: 2023 年 9 月 |
