本站電子書

您可以在這些電子書店找到本站電子書: Google Play 圖書iBooks StoreHyReadReadmooPubu
===>>>本站推出學習遊戲意見調查<<<===《如何自學程式設計》入選 Google Play 台灣地區2016年度最佳書籍

Python 入門指南 V2.00 - 單元 13 範例及練習程式碼

class_demo10.py


"""An example of the Demo class.

   This module demonstrates the docstring. 
"""

# This is a comment of a class.
class Demo:
   """A docsting of the class."""
   # This is a comment of the method.
   def __init__(self, v1=11, v2=22):
      """A docsting of the __init__."""
      self.__a = v1
      self.__b = v2
   
   # This is a comment of a method.
   def do_something(self):
      """A docsting of a method."""
      return self.__a + self.__b

if __name__ == "__main__":
   d = Demo(12, 34)
   print(d.do_something())
 
# 檔名: class_demo10.py 
# 作者: Kaiching Chang 
# 時間: July, 2014

the end

沒有留言: