Skip to content

Commit

Permalink
增添单例模式
Browse files Browse the repository at this point in the history
  • Loading branch information
sty945 committed Mar 10, 2018
1 parent 81c88e0 commit 6f1b92c
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -521,7 +521,7 @@ ps: `__metaclass__`是创建类时起作用.所以我们可以分别使用`__met
> ​ 单例模式是一种常用的软件设计模式。在它的核心结构中只包含一个被称为单例类的特殊类。通过单例模式可以保证系统中一个类只有一个实例而且该实例易于外界访问,从而方便对实例个数的控制并节约系统资源。如果希望在系统中某个类的对象只能存在一个,单例模式是最好的解决方案。
>
> `__new__()``__init__()`之前被调用,用于生成实例对象。利用这个方法和类的属性的特点可以实现设计模式的单例模式。单例模式是指创建唯一对象,单例模式设计的类只能实例
[伯乐在线详细解释](http://python.jobbole.com/87294/)
**这个绝对常考啊.绝对要记住1~2个方法,当时面试官是让手写的.**

### 1 使用`__new__`方法
Expand Down

0 comments on commit 6f1b92c

Please sign in to comment.