0
点赞
收藏
分享

微信扫一扫

Python 3面向对象编程(第2版)- Chapter2 Case Study

jjt二向箔 2022-05-01 阅读 54
python

Test1 

>>> notebook.py

import datetime

# Store the next available id for all new notes
last_id = 0

class Note:
    '''Represent a note in the notebook. Match against a
    sring in searches and store tage for each note.'''

    def __init__(self, memo, tags = ''):
        '''initialize a note with memo and optional space-seperated tags.
        Automatically set the note`s creation date and a unique id.'''
        self.memo = memo
        self.tags = tags
        self.creation_date = datetime.date.today()
        global last_id
        last_id += 1
        self.id = last_id

    def match(self, filter):
        '''Determine if this note matches the filter text, Return True if it matches,
        False otherwise
        Serach is case sen
举报

相关推荐

0 条评论