我是初學者。對於學習的緣故,我必須寫一個類在python它接受最多3個不同的參數(A,B,C):像Python類 - 如何創建接受未定義數量參數的類?
class random(object):
def __init__(self,a,b,c):
blah blah blah
如何讓這個:
如果沒有參數輸入,它會做一件事。
例如:
「測試=隨機()」,在這種情況下假設A = B = C = 0
如果輸入一個參數,它是另一回事。
例如:
"test=random(2)", in this case a=2 ,b=c=0, and then run some case specific codes/instrutctions
和等
像如何與內置函數/類 「範圍」,在這裏你可以使用
範圍(9) 範圍(3,9) 範圍(3,9,2)
如果你知道我的意思。
謝謝