- 類別的變數可以自己命名
- 類別方法第一個參數為類別變數
class cyl_ticket2:
def __init__(myparam,order,fund,people):
myparam.order = order
myparam.fund = fund
myparam.people = people
def info(aaa): #aaa=類別變數
print("訂購人:"+aaa.order+"共買了"+str(aaa.people)+"張門票共"+str(aaa.fund*aaa.people)+"元")
data = cyl_ticket2("ruyi",200,7)
data.info()
Yiru@Studio - 關於我 - 意如