-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path__init__fang-fa.html
170 lines (150 loc) · 6.48 KB
/
__init__fang-fa.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
<!DOCTYPE html>
<!--[if IEMobile 7 ]><html class="no-js iem7"><![endif]-->
<!--[if lt IE 9]><html class="no-js lte-ie8"><![endif]-->
<!--[if (gt IE 8)|(gt IEMobile 7)|!(IEMobile)|!(IE)]><!--><html class="no-js" lang="en"><!--<![endif]-->
<head>
<link rel="short icon" href="http://softing.qiniudn.com/20140603011448867_easyicon_net_128.ico" type="image/x-ico">
<meta charset="utf-8">
<title>__init__()方法</title>
<meta name="author" content="tulpar">
<!-- http://t.co/dKP3o1e -->
<meta name="HandheldFriendly" content="True">
<meta name="MobileOptimized" content="320">
<meta name="viewport" content="width=device-width, initial-scale=1">
<!-- <link href="/favicon.png" rel="icon"> -->
<link href="/theme/css/main.css" media="screen, projection"
rel="stylesheet" type="text/css">
<script src="/theme/js/modernizr-2.0.js"></script>
<script src="/theme/js/ender.js"></script>
<script src="/theme/js/octopress.js" type="text/javascript"></script>
<link href="http://fonts.googleapis.com/css?family=PT+Serif:regular,italic,bold,bolditalic"
rel="stylesheet" type="text/css">
<link href="http://fonts.googleapis.com/css?family=PT+Sans:regular,italic,bold,bolditalic"
rel="stylesheet" type="text/css">
</head>
<body>
<header role="banner"><hgroup>
<h1><a href="/">Dreaming</a></h1>
</hgroup></header>
<nav role="navigation"><ul class="subscription" data-subscription="rss">
</ul>
<ul class="main-navigation">
<li class="active">
<a href="/category/it.html">It</a>
</li>
<li >
<a href="/category/life.html">Life</a>
</li>
</ul></nav>
<div id="main">
<div id="content">
<div>
<article class="hentry" role="article">
<header>
<h1 class="entry-title">__init__()方法</h1>
<p class="meta"><time datetime="2014-07-07T00:00:00+08:00" pubdate>Mon 07 July 2014</time></p>
</header>
<div class="entry-content"><h3>首先复习一下,<a href="http://tulpar008.github.io/pythonzhong-__shuang-xia-hua-xian-de-zuo-yong.html">__(双下划线)的作用</a></h3>
<ul>
<li>
<p>Python中默认的成员函数,成员变量都是公开的(public),而且python中没有类似public,private等关键词来修饰成员函数,成员变量。 </p>
</li>
<li>
<p>可有时候需要用到私有变量,因此诞生了__。 </p>
</li>
<li>
<p>变量名或函数名前加上 ”__“两个下划线,那么这个函数或变量就会为私有的了。</p>
</li>
<li>
<p>私有意味着只有内部能使用,对外部隐藏。 </p>
</li>
<li>
<p>在内部,python使用一种 name mangling 技术,将 __membername替换成 _classname__membername来使用。 <br />
在外部,使用原来的私有成员的名字时,会提示找不到。(达到了隐藏的效果) </p>
</li>
</ul>
<hr />
<p>很显然,__init__是个私有函数</p>
<h5>__init__方法在类的一个对象被建立时,马上运行。这个方法可以用来对你的对象做一些你希望的 初始化 。</h5>
<h6>注意,这个名称的开始和结尾都是双下划线。</h6></div>
<footer>
<p class="meta">
<span class="byline author vcard">
Posted by <span class="fn">tulpar</span>
</span>
<time datetime="2014-07-07T00:00:00+08:00" pubdate>Mon 07 July 2014</time> <span class="categories">
<a class="category" href="/tag/python.html">Python</a>
</span>
</p><div class="sharing">
</div> </footer>
</article>
<!-- Duoshuo Comment BEGIN -->
<div class="ds-thread"></div>
<script type="text/javascript">
var duoshuoQuery = {short_name:"tlbog"};
(function() {
var ds = document.createElement('script');
ds.type = 'text/javascript';ds.async = true;
ds.src = 'http://static.duoshuo.com/embed.js';
ds.charset = 'UTF-8';
(document.getElementsByTagName('head')[0]
|| document.getElementsByTagName('body')[0]).appendChild(ds);
})();
</script>
<!-- Duoshuo Comment END -->
</div>
<aside class="sidebar">
<section>
<h1>Recent Posts</h1>
<ul id="recent_posts">
<li class="post">
<a href="/xie-bo-ke-jiao-ben.html">写博客脚本</a>
</li>
<li class="post">
<a href="/gong-zuo-shi-de-sui-bi.html">工作时的随笔</a>
</li>
<li class="post">
<a href="/ce-shi-wen-zhang.html">测试文章</a>
</li>
<li class="post">
<a href="/djangokai-qi-the-sites-framework.html">Django开启 the sites framework</a>
</li>
<li class="post">
<a href="/django-17shi-yong.html">Django 1.7试用</a>
</li>
</ul>
</section>
<section>
<h1>Categories</h1>
<ul id="recent_posts">
<li><a href="/category/it.html">It</a></li>
<li><a href="/category/life.html">Life</a></li>
</ul>
</section>
<section>
<h1>Tags</h1>
<a href="/tag/mysql.html">Mysql</a>, <a href="/tag/tmux.html">Tmux</a>, <a href="/tag/fan-qiang.html">翻墙</a>, <a href="/tag/linux.html">Linux</a>, <a href="/tag/edx.html">Edx</a>, <a href="/tag/virtualbox.html">VirtualBox</a>, <a href="/tag/wo-ai-wo-jia.html">我爱我家</a>, <a href="/tag/userena.html">userena</a>, <a href="/tag/xadmin.html">Xadmin</a>, <a href="/tag/shell.html">Shell</a>, <a href="/tag/python.html">Python</a>, <a href="/tag/djangopython.html">Django,python</a>, <a href="/tag/ssh.html">ssh</a>, <a href="/tag/ubuntu.html">Ubuntu</a>, <a href="/tag/git.html">Git</a>, <a href="/tag/ce-shi.html">测试</a>, <a href="/tag/ueditor.html">Ueditor</a>, <a href="/tag/github.html">Github</a>, <a href="/tag/socketio.html">Socket.io</a>, <a href="/tag/django.html">Django</a>, <a href="/tag/du-shu.html">读书</a>, <a href="/tag/bo-ke.html">博客</a>, <a href="/tag/ngrok.html">ngrok</a> </section>
<section>
<h1>Social</h1>
<ul>
<li><a href="http://izda.com" target="_blank">ئىزدە</a></li>
<li><a href="http://www.google.com" target="_blank">Google</a></li>
<li><a href="http://www.zhihu.com/" target="_blank">知乎</a></li>
<li><a href="http://www.douban.com/" target="_blank">豆瓣</a></li>
</ul>
</section>
<section>
<h1>Blogroll</h1>
<ul>
<li><a href="https://github.com/tulpar008" target="_blank">My Github</a></li>
<li><a href="#" target="_blank">[email protected]</a></li>
</ul>
</section>
</aside> </div>
</div>
<footer role="contentinfo"><p>
Copyright © 2013-2015 - tulpar -
<span class="credit">Powered by <a href="http://getpelican.com">Pelican</a></span>
</p></footer>
</body>
</html>