Python練習 #9-建立實體物件

by Gemma

本周目標

熟悉Python的基礎語法與資料結構

任務

  • 學習函數的定義和使用(Parameters、Return Values)
  • 練習設計和使用函數,並完成更多字串處理練習(例如文字查找和替換)
  • 學習file open, write, read指令
  • 學習json指令
  • 練習從公開網站讀取資料並寫入文件
  • 建立實體物件與實體屬性

專案練習

class Fullname:
    def __init__(self,x,y):
        self.x=x
        self.y=y

f1=Fullname("Will","Liu")
print(f1.x,f1.y)
f2=Fullname("Steve","Hung")
print(f2.x,f2.y)

Output

Will Liu
Steve Hung

You may also like

Leave a Comment