class TwoCard:
def __init__(self, card1, card2):
self.card1 = card1
self.card2 = card2
如何拨打card1或2
答案 0 :(得分:2)
class TwoCard:
def __init__(self, card1, card2):
self.card1 = card1
self.card2 = card2
def f():
print('f called')
def g():
print('g called')
two = TwoCard(f, g)
two.card1() # call card1
two.card2() # call card2
输出:
f called
g called