0
点赞
收藏
分享

微信扫一扫

Notepad++工具通过正则表达式批量替换内容

“”“单例模式”“”
在这里插入图片描述
在这里插入图片描述

“”“工厂模式”“”

class Person:
    pass


class Worker(Person):
    pass


class Student(Person):
    pass


class Teacher(Person):
    pass


class Factory:
    def get_person(self, p_type):
        if p_type == 'w':
            return Worker()
        elif p_type == 's':
            return Student()
        else:
            return Teacher()


pf = Factory()
worker = pf.get_person('w')
stu = pf.get_person('s')
teacher = pf.get_person('t')

在这里插入图片描述

举报

相关推荐

0 条评论