
Python 入門指南 5.0
exercise1603.py
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | # 示範靜態方法 class Exercise1603: # 定義印出參數的靜態方法 @staticmethod def print_message(p): # 印出參數字串 print(p) # 定義使用靜態方法的實體方法 def print_hello(self): # 印出指定字串 self.print_message("Hello") # 以下是執行部分 # 建立 Exercise1603 類別的物件 e = Exercise1603() # 利用實體方法印出指定字串 e.print_hello() # 檔名: exercise1603.py # 說明:《Python入門指南》的練習 # 網站: http://kaiching.org # 作者: 張凱慶 # 時間: 2023 年 9 月 |
