diff options
-rw-r--r-- | LectureNotesOnPython.rst | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/LectureNotesOnPython.rst b/LectureNotesOnPython.rst index 647835a..c8d4c06 100644 --- a/LectureNotesOnPython.rst +++ b/LectureNotesOnPython.rst @@ -1979,7 +1979,10 @@ IS-A 。 一手牌是一副牌。 for card in self.cards: res.append(str(card)) return '\n'.join(res) - + + def __len__(self): + return len(self.cards) + def add_card(self, card): """Adds a card to the deck. @@ -2036,9 +2039,9 @@ IS-A 。 一手牌是一副牌。 deck.move_cards(hand, 5) hand.sort() print(hand) + hand.move_cards(deck, 5) - 用于数据库操作。以 SQLite 为例子。 |