-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
551 lines (397 loc) · 52.9 KB
/
index.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
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>aliyarly</title>
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
<meta property="og:type" content="website">
<meta property="og:title" content="aliyarly">
<meta property="og:url" content="http://yoursite.com/index.html">
<meta property="og:site_name" content="aliyarly">
<meta name="twitter:card" content="summary">
<meta name="twitter:title" content="aliyarly">
<link rel="alternate" href="/atom.xml" title="aliyarly" type="application/atom+xml">
<link rel="icon" href="/favicon.png">
<link href="//fonts.googleapis.com/css?family=Source+Code+Pro" rel="stylesheet" type="text/css">
<link rel="stylesheet" href="/css/style.css">
</head>
<body>
<div id="container">
<div id="wrap">
<header id="header">
<div id="banner"></div>
<div id="header-outer" class="outer">
<div id="header-title" class="inner">
<h1 id="logo-wrap">
<a href="/" id="logo">aliyarly</a>
</h1>
</div>
<div id="header-inner" class="inner">
<nav id="main-nav">
<a id="main-nav-toggle" class="nav-icon"></a>
<a class="main-nav-link" href="/">Home</a>
<a class="main-nav-link" href="/archives">Archives</a>
</nav>
<nav id="sub-nav">
<a id="nav-rss-link" class="nav-icon" href="/atom.xml" title="RSS Feed"></a>
<a id="nav-search-btn" class="nav-icon" title="Search"></a>
</nav>
<div id="search-form-wrap">
<form action="//google.com/search" method="get" accept-charset="UTF-8" class="search-form"><input type="search" name="q" class="search-form-input" placeholder="Search"><button type="submit" class="search-form-submit"></button><input type="hidden" name="sitesearch" value="http://yoursite.com"></form>
</div>
</div>
</div>
</header>
<div class="outer">
<section id="main">
<article id="post-python-参数传递方式" class="article article-type-post" itemscope itemprop="blogPost">
<div class="article-meta">
<a href="/2017/07/13/python-参数传递方式/" class="article-date">
<time datetime="2017-07-13T12:10:05.000Z" itemprop="datePublished">2017-07-13</time>
</a>
</div>
<div class="article-inner">
<header class="article-header">
<h1 itemprop="name">
<a class="article-title" href="/2017/07/13/python-参数传递方式/">python_参数传递方式</a>
</h1>
</header>
<div class="article-entry" itemprop="articleBody">
<h2 id="python中一切皆为对象"><a href="#python中一切皆为对象" class="headerlink" title="python中一切皆为对象"></a>python中一切皆为对象</h2><h3 id="对象"><a href="#对象" class="headerlink" title="对象"></a>对象</h3><p>数字是对象,列表是对象,函数也是对象,任何东西都是对象</p>
<h3 id="变量"><a href="#变量" class="headerlink" title="变量"></a>变量</h3><p>变量是对象的一个引用(又称为名字或者标签),对象的操作都是通过引用来完成的</p>
<p>变量本身没有类型信息,类型信息存储在对象中</p>
<p>赋值操作 = 就是把一个名字绑定到一个对象上。就像给对象添加一个标签</p>
<h3 id="函数参数"><a href="#函数参数" class="headerlink" title="函数参数"></a>函数参数</h3><p><code>本质上应该是传递的对象,根据对象的类型来确定传递的方式</code>:</p>
<ul>
<li>如果是不可变的对象则可以理解为按值传递</li>
</ul>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div><div class="line">11</div><div class="line">12</div><div class="line">13</div></pre></td><td class="code"><pre><div class="line">def bar(args):</div><div class="line"> args.append(1)</div><div class="line"></div><div class="line">b = []</div><div class="line">print(b)</div><div class="line"># 输出:[]</div><div class="line">print(id(b)) </div><div class="line"># 输出:4324106952</div><div class="line">bar(b)</div><div class="line">print(b)</div><div class="line"># 输出:[1]</div><div class="line">print(id(b)) </div><div class="line"># 输出:4324106952</div></pre></td></tr></table></figure>
<ul>
<li>是可变对象则可以理解为按引用传递</li>
</ul>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div><div class="line">11</div><div class="line">12</div><div class="line">13</div><div class="line">14</div><div class="line">15</div><div class="line">16</div></pre></td><td class="code"><pre><div class="line">def demo2(item, item_list=[]):</div><div class="line"> item_list.append(item)</div><div class="line"> return item_list</div><div class="line"></div><div class="line">print(demo2(1))</div><div class="line"># [1]</div><div class="line">print(demo(2))</div><div class="line"># [1,2]</div><div class="line"></div><div class="line"># 上述方式创建的函数是不安全的,函数参数只在定义时初始化依次,每次操作时对一个对象进行修改,需优化如下:</div><div class="line"></div><div class="line">def demo2(item, item_list=None):</div><div class="line"> if item_list is None:</div><div class="line"> item_list = []</div><div class="line"> item_list.append(item)</div><div class="line"> return item_list</div></pre></td></tr></table></figure>
</div>
<footer class="article-footer">
<a data-url="http://yoursite.com/2017/07/13/python-参数传递方式/" data-id="cj52eurat00005ahqyjudci35" class="article-share-link">Share</a>
</footer>
</div>
</article>
<article id="post-python-迭代器" class="article article-type-post" itemscope itemprop="blogPost">
<div class="article-meta">
<a href="/2017/07/07/python-迭代器/" class="article-date">
<time datetime="2017-07-07T06:01:40.000Z" itemprop="datePublished">2017-07-07</time>
</a>
</div>
<div class="article-inner">
<header class="article-header">
<h1 itemprop="name">
<a class="article-title" href="/2017/07/07/python-迭代器/">python-迭代器</a>
</h1>
</header>
<div class="article-entry" itemprop="articleBody">
<h2 id="迭代器协议"><a href="#迭代器协议" class="headerlink" title="迭代器协议"></a>迭代器协议</h2><ol>
<li>当你执行如下代码时所涉及的步骤:<figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div></pre></td><td class="code"><pre><div class="line">for x in mylist:</div><div class="line"> ...loop body...</div></pre></td></tr></table></figure>
</li>
</ol>
<ul>
<li><p>获取mylist的迭代器,即调用<code>iter(mylist)</code>,返回一个一个具有<code>next方法的一个对象</code></p>
</li>
<li><p>在第一次循环的时候,调用上述返回的对象的next方法,获取值传递给x,执行相应的循环体</p>
</li>
<li><p>按照步骤二重复执行,直到存在<code>StopInteration</code>,for循环即停止返回</p>
</li>
</ul>
<ol>
<li>可迭代的对象</li>
</ol>
<p>能够循环遍历访问对象的各个元素,能够使用<code>for ... in ...</code>,所有的数据依次加载进内存中,且对象是可重复使用<br>例如:list, turple,dict,set等</p>
<p>对象的必须实现<code>__iter__</code>方法,将相应的对象转换为可迭代对象,内置数据结构是包含的.</p>
<ol>
<li>获取迭代器对象</li>
</ol>
<p>从可迭代的对象获取相应的迭代器(对象)</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div></pre></td><td class="code"><pre><div class="line">lst=[1,2,3]</div><div class="line">l = iter(lst)</div><div class="line"># Out[3]: <listiterator at 0x7fd402c37790></div></pre></td></tr></table></figure>
<ol>
<li>迭代器方法</li>
</ol>
<p>主要包含<code>next()</code>方法,用于迭代回去可迭代对象的元素</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div><div class="line">11</div><div class="line">12</div><div class="line">13</div><div class="line">14</div><div class="line">15</div></pre></td><td class="code"><pre><div class="line">l.next()</div><div class="line">Out[5]: 1</div><div class="line">In [6]: l.next()</div><div class="line">Out[6]: 2</div><div class="line"></div><div class="line">In [7]: l.next()</div><div class="line">Out[7]: 3</div><div class="line"></div><div class="line">In [8]: l.next()</div><div class="line">---------------------------------------------------------------------------</div><div class="line">StopIteration Traceback (most recent call last)</div><div class="line"><ipython-input-8-49b5b93d8a22> in <module>()</div><div class="line">----> 1 l.next()</div><div class="line"></div><div class="line">StopIteration:</div></pre></td></tr></table></figure>
<ol>
<li>迭代器的语法糖</li>
</ol>
<p>在for循环中,Python将自动调用工厂函数iter()获得迭代器,自动调用next()获取元素,还完成了检查StopIteration异常的处理</p>
<p>只要是实现了<code>__iter__()</code>方法的对象,就可以使用迭代器进行访问,例如1部分的实例.</p>
<ol>
<li><p>迭代器类实例</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div><div class="line">11</div><div class="line">12</div><div class="line">13</div><div class="line">14</div><div class="line">15</div><div class="line">16</div><div class="line">17</div><div class="line">18</div><div class="line">19</div><div class="line">20</div><div class="line">21</div></pre></td><td class="code"><pre><div class="line"># 斐波那契数列</div><div class="line"># -*- coding: cp936 -*-</div><div class="line">class Fabs(object):</div><div class="line"> def __init__(self,max):</div><div class="line"> self.max = max</div><div class="line"> self.n, self.a, self.b = 0, 0, 1 #特别指出:第0项是0,第1项是第一个1.整个数列从1开始</div><div class="line"></div><div class="line"> def __iter__(self):</div><div class="line"> return self</div><div class="line"> </div><div class="line"> def next(self):</div><div class="line"> if self.n < self.max:</div><div class="line"> r = self.b</div><div class="line"> self.a, self.b = self.b, self.a + self.b</div><div class="line"> self.n = self.n + 1</div><div class="line"> return r</div><div class="line"> raise StopIteration()</div><div class="line"></div><div class="line">print Fabs(5)</div><div class="line">for key in Fabs(5):</div><div class="line"> print key</div></pre></td></tr></table></figure>
</li>
<li><p>迭代器优点</p>
</li>
</ol>
<p>不必事先准备好整个迭代过程中所有的元素。迭代器仅仅在迭代到某个元素时才计算该元素,而在这之前或之后,元素可以不存在或者被销毁。适用于大量数据.</p>
<p>提供了一个统一的访问集合的接口,只要定义了<code>__iter__()</code>方法对象,就可以使用迭代器访问</p>
</div>
<footer class="article-footer">
<a data-url="http://yoursite.com/2017/07/07/python-迭代器/" data-id="cj52eurb600055ahqvphxni26" class="article-share-link">Share</a>
</footer>
</div>
</article>
<article id="post-go-json解码和执行外部脚本" class="article article-type-post" itemscope itemprop="blogPost">
<div class="article-meta">
<a href="/2017/07/07/go-json解码和执行外部脚本/" class="article-date">
<time datetime="2017-07-07T03:32:26.000Z" itemprop="datePublished">2017-07-07</time>
</a>
</div>
<div class="article-inner">
<header class="article-header">
<h1 itemprop="name">
<a class="article-title" href="/2017/07/07/go-json解码和执行外部脚本/">go-json解码和执行外部脚本</a>
</h1>
</header>
<div class="article-entry" itemprop="articleBody">
<h2 id="go-解码json字符串"><a href="#go-解码json字符串" class="headerlink" title="go 解码json字符串"></a>go 解码json字符串</h2><figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div></pre></td><td class="code"><pre><div class="line">import encoding/json</div></pre></td></tr></table></figure>
<p>Go对于json有官方自己的解析包,先谈一下json的解码方式。解码的api如下:<br><figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div></pre></td><td class="code"><pre><div class="line">func Unmarshal (data []byte, v interface{})</div></pre></td></tr></table></figure></p>
<h3 id="解析到结构体-最常用的方式"><a href="#解析到结构体-最常用的方式" class="headerlink" title="解析到结构体(最常用的方式)"></a>解析到结构体(最常用的方式)</h3><p>需要注意的是:</p>
<p>(1)解析到结构体时只能解析到结构体中的首字母大写的变量</p>
<p>(2)结构体中数值对应json中的key是大小写不敏感的</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div><div class="line">11</div><div class="line">12</div><div class="line">13</div><div class="line">14</div><div class="line">15</div><div class="line">16</div><div class="line">17</div><div class="line">18</div><div class="line">19</div><div class="line">20</div><div class="line">21</div><div class="line">22</div><div class="line">23</div></pre></td><td class="code"><pre><div class="line">type T struct {</div><div class="line"> Cmd string</div><div class="line"> Args string</div><div class="line"> }</div><div class="line">for {</div><div class="line"> var msg T</div><div class="line"></div><div class="line"> err := websocket.JSON.Receive(we.ws, &msg)</div><div class="line"> if err != nil {</div><div class="line"> //err == EOF if ws close connection from client</div><div class="line"> we.log.Debug("websocket", "Cannot receive data from client: %s", err)</div><div class="line"> if err != io.EOF {</div><div class="line"> we.log.Debug("websocket", "Cannot receive: %s", err)</div><div class="line"> }</div><div class="line"> break</div><div class="line"> }</div><div class="line"> we.log.Debug("websocket", "receive json data is %+v, %s, %s", msg, msg.Cmd, msg.Args)</div><div class="line"> if strings.Contains(msg.Cmd, "flash") || strings.Contains(msg.Cmd, "run") {</div><div class="line"> we.log.Associate("command", msg.Cmd)</div><div class="line"> process = we.start_cmd_process(msg.Cmd)</div><div class="line"> break</div><div class="line"> }</div><div class="line"> }</div></pre></td></tr></table></figure>
<h3 id="解析到空的接口"><a href="#解析到空的接口" class="headerlink" title="解析到空的接口"></a>解析到空的接口</h3><p>需要注意的是:</p>
<p>(1)json中的数字解码到map中统一是float64类型,如果实际中采用其它类型需要手动转换</p>
<p>(2)map中对应json的key是大小写敏感的,同时也没有结构体中要求的首字母大写<br><figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div><div class="line">11</div><div class="line">12</div><div class="line">13</div><div class="line">14</div><div class="line">15</div><div class="line">16</div><div class="line">17</div><div class="line">18</div><div class="line">19</div><div class="line">20</div><div class="line">21</div><div class="line">22</div><div class="line">23</div><div class="line">24</div><div class="line">25</div><div class="line">26</div><div class="line">27</div><div class="line">28</div><div class="line">29</div><div class="line">30</div><div class="line">31</div><div class="line">32</div><div class="line">33</div><div class="line">34</div><div class="line">35</div><div class="line">36</div><div class="line">37</div></pre></td><td class="code"><pre><div class="line">package main </div><div class="line"></div><div class="line">import (</div><div class="line"> "encoding/json"</div><div class="line"> "fmt"</div><div class="line">)</div><div class="line"></div><div class="line">func main() {</div><div class="line"> str := `{"changes": [{"armid":3,"Index":5}, {"armid":3,"Index":6}]}`</div><div class="line"> var msg map[string]interface{}</div><div class="line"> err := json.Unmarshal([]byte(str), &msg)</div><div class="line"> if err!=nil {</div><div class="line"> fmt.Println("fuck",err)</div><div class="line"> }</div><div class="line"> fmt.Println(msg)</div><div class="line"> </div><div class="line"> changes,ok := msg["changes"].([](interface{}))</div><div class="line"> if !ok {</div><div class="line"> fmt.Println("Can't convert msg to []interface")</div><div class="line"> }</div><div class="line"> </div><div class="line"> for _ ,ichange := range changes {</div><div class="line"> change, ok := ichange.(map[string]interface{})</div><div class="line"> if !ok {</div><div class="line"> fmt.Println("cant convert ichange to map[string]interface{}")</div><div class="line"> }</div><div class="line"> Index, ok := change["Index"].(float64)</div><div class="line"> if !ok { </div><div class="line"> fmt.Println("cant convert Index to float64")</div><div class="line"> }</div><div class="line"> armid,ok := change["armid"].(float64)</div><div class="line"> if !ok { </div><div class="line"> fmt.Println("cant convert armid to float")</div><div class="line"> }</div><div class="line"> fmt.Println(Index,armid)</div><div class="line"> }</div><div class="line">}</div></pre></td></tr></table></figure></p>
<h2 id="go-执行外部的python脚本"><a href="#go-执行外部的python脚本" class="headerlink" title="go 执行外部的python脚本"></a>go 执行外部的python脚本</h2><ol>
<li><p>首先确保python脚本是有权限的,并且可以执行的,即在脚本的首行指定其解释器与运行环境,例如</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div></pre></td><td class="code"><pre><div class="line">#!/usr/bin/env python2</div></pre></td></tr></table></figure>
</li>
<li><p>执行脚本,采用内置的<code>exec</code><a href="https://golang.org/pkg/os/exec" target="_blank" rel="external">https://golang.org/pkg/os/exec</a>模块</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div><div class="line">11</div><div class="line">12</div><div class="line">13</div><div class="line">14</div><div class="line">15</div><div class="line">16</div><div class="line">17</div><div class="line">18</div><div class="line">19</div><div class="line">20</div><div class="line">21</div><div class="line">22</div><div class="line">23</div><div class="line">24</div><div class="line">25</div><div class="line">26</div><div class="line">27</div><div class="line">28</div><div class="line">29</div><div class="line">30</div><div class="line">31</div><div class="line">32</div><div class="line">33</div><div class="line">34</div><div class="line">35</div><div class="line">36</div><div class="line">37</div><div class="line">38</div><div class="line">39</div><div class="line">40</div><div class="line">41</div><div class="line">42</div><div class="line">43</div><div class="line">44</div><div class="line">45</div><div class="line">46</div><div class="line">47</div><div class="line">48</div><div class="line">49</div><div class="line">50</div><div class="line">51</div><div class="line">52</div><div class="line">53</div><div class="line">54</div><div class="line">55</div></pre></td><td class="code"><pre><div class="line">package main</div><div class="line">import (</div><div class="line"> "io"</div><div class="line"> "os/exec"</div><div class="line"> "fmt"</div><div class="line">)</div><div class="line"></div><div class="line">type LaunchedProcess struct {</div><div class="line"> cmd *exec.Cmd</div><div class="line"> stdin io.WriteCloser</div><div class="line"> stdout io.ReadCloser</div><div class="line"> stderr io.ReadCloser</div><div class="line">}</div><div class="line"></div><div class="line">// 对外部执行系统命令的简单封装,用于异步执行,并将重定向输入,输出和错误信息</div><div class="line">func launchCmd(commandName string, commandArgs []string, env []string) (*LaunchedProcess, error) {</div><div class="line"> // 返回可执行的命令行结构变量</div><div class="line"> cmd := exec.Command(commandName, commandArgs...)</div><div class="line"> cmd.Env = env</div><div class="line"></div><div class="line"> stdout, err := cmd.StdoutPipe()</div><div class="line"> if err != nil {</div><div class="line"> return nil, err</div><div class="line"> }</div><div class="line"></div><div class="line"> stderr, err := cmd.StderrPipe()</div><div class="line"> if err != nil {</div><div class="line"> return nil, err</div><div class="line"> }</div><div class="line"></div><div class="line"> stdin, err := cmd.StdinPipe()</div><div class="line"> if err != nil {</div><div class="line"> return nil, err</div><div class="line"> }</div><div class="line"> //开始执行命令,并不等待改命令执行完毕,即出发执行便返回</div><div class="line"> // cmd.Run()会等待命令执行完毕</div><div class="line"> err = cmd.Start()</div><div class="line"> if err != nil {</div><div class="line"> return nil, err</div><div class="line"> }</div><div class="line"></div><div class="line"> return &LaunchedProcess{cmd, stdin, stdout, stderr}, err</div><div class="line">}</div><div class="line"></div><div class="line">func main() {</div><div class="line"> // 待执行脚本的绝对路径或者相对改应用的相对路径</div><div class="line"> command := "/home/saic/Desktop/lyn/autotest/cheji-platform/run.py"</div><div class="line"> CommandArgs := []string{}</div><div class="line"> env := []string{}</div><div class="line"> launched, err := launchCmd(command, CommandArgs, env)</div><div class="line"> if err != nil {</div><div class="line"> fmt.Printf("Could not launch process")</div><div class="line"> }</div><div class="line"> fmt.Printf("Process opend is %d", launched.cmd.Process.Pid)</div><div class="line">}</div></pre></td></tr></table></figure>
</li>
</ol>
</div>
<footer class="article-footer">
<a data-url="http://yoursite.com/2017/07/07/go-json解码和执行外部脚本/" data-id="cj52euray00015ahqmmbbtjsm" class="article-share-link">Share</a>
</footer>
</div>
</article>
<article id="post-python基本数据结构和底层实现原理" class="article article-type-post" itemscope itemprop="blogPost">
<div class="article-meta">
<a href="/2017/07/04/python基本数据结构和底层实现原理/" class="article-date">
<time datetime="2017-07-04T01:49:07.000Z" itemprop="datePublished">2017-07-04</time>
</a>
</div>
<div class="article-inner">
<header class="article-header">
<h1 itemprop="name">
<a class="article-title" href="/2017/07/04/python基本数据结构和底层实现原理/">python基本数据结构和底层实现原理</a>
</h1>
</header>
<div class="article-entry" itemprop="articleBody">
<h1 id="List的实现原理"><a href="#List的实现原理" class="headerlink" title="List的实现原理"></a>List的实现原理</h1><h2 id="List-是一种元素个数和数据可变的线性表,可以加入和删除,在各种操作中维持已有元素的顺序."><a href="#List-是一种元素个数和数据可变的线性表,可以加入和删除,在各种操作中维持已有元素的顺序." class="headerlink" title="List 是一种元素个数和数据可变的线性表,可以加入和删除,在各种操作中维持已有元素的顺序."></a>List 是一种元素个数和数据可变的线性表,可以加入和删除,在各种操作中维持已有元素的顺序.</h2><p>线性表:具有元素顺序关系的某类数据对象的集合,支持创建,索引,动态改变表,两个表的操作</p>
<p>线性表的实现:</p>
<ol>
<li><code>顺序表</code>:将表中元素顺序底存放在一大块连续的存储区域,元素间的关系由它们的存储顺序自然表示</li>
<li><code>链接表</code>:将表元素存放在通过链接构造起来的一系列的存储块里,一般存在单链表,循环单链表,双链表</li>
</ol>
<p>顺序表结构:</p>
<ol>
<li><p>一体式结构:将表的全局对象(表的容量max和当前已存储的元素个数num)和数据存储区以连续的方式放置在一块连续的存储区</p>
</li>
<li><p>分离式结构: 表对象只保存容量和元素个数,以及指向存储区域的链接引用对象,使得两者的存储相分离,通过链接来连接表对象和存储数据对象(创建管理较复杂)</p>
</li>
</ol>
<p>基于分离式线性表的存储区扩容:</p>
<ul>
<li>申请一块更大的元素存储区域 </li>
<li>把原先表中的元素复制到新的存储区域</li>
<li>改变表对象的元素区链接</li>
<li>实际加入新的元素</li>
</ul>
<h2 id="python的list的实际策略:"><a href="#python的list的实际策略:" class="headerlink" title="python的list的实际策略:"></a>python的list的实际策略:</h2><pre><code>List 采用分离式技术实现的动态顺序表
</code></pre><p> 在建立空表或者很小的表的时候,系统分配一块能够容纳8个元素的存储区域,在执行插入操作时,如果元素区满就换一块4倍大的存储区域,但是如果表很大时,换存储去时容量加倍<br>,后面减少倍数,是为了避免出现过多空闲的存储位置.</p>
<h2 id="list操作的基本性质"><a href="#list操作的基本性质" class="headerlink" title="list操作的基本性质"></a>list操作的基本性质</h2><p>len()的时间复杂度为O(1)</p>
<p>元素按索引访问和赋值,尾端加入和删除时间复杂度为O(1),根据相应的索引,能够直接计算出相应的内存地址</p>
<p>一般位置元素的加入,切片,拼接的时间复杂度O(n)</p>
<p>特殊: clear(),reverse(),sort(排序算法相关)</p>
<h1 id="Turple的实现原理"><a href="#Turple的实现原理" class="headerlink" title="Turple的实现原理"></a>Turple的实现原理</h1><h2 id="元素数据不可变的线性表,一旦创建就不能更改,具有顺序结构"><a href="#元素数据不可变的线性表,一旦创建就不能更改,具有顺序结构" class="headerlink" title="元素数据不可变的线性表,一旦创建就不能更改,具有顺序结构"></a>元素数据不可变的线性表,一旦创建就不能更改,具有顺序结构</h2><h2 id="python的turple的实现策略:"><a href="#python的turple的实现策略:" class="headerlink" title="python的turple的实现策略:"></a>python的turple的实现策略:</h2><p> Turple采用<code>一体式结构的线性表</code>,按建立时确定的元素个数来分配内存,一旦创建就不能进行扩容</p>
<h1 id="String的实现原理"><a href="#String的实现原理" class="headerlink" title="String的实现原理"></a>String的实现原理</h1><h2 id="字符串是字符的线性序列,采用线性表的各种实现技术实现"><a href="#字符串是字符的线性序列,采用线性表的各种实现技术实现" class="headerlink" title="字符串是字符的线性序列,采用线性表的各种实现技术实现"></a>字符串是字符的线性序列,采用线性表的各种实现技术实现</h2><h2 id="python的str的实现策略:"><a href="#python的str的实现策略:" class="headerlink" title="python的str的实现策略:"></a>python的str的实现策略:</h2><p>字符串是不可变的类型,采用<code>一体式顺序表实现</code></p>
<p>python语言的正则表达式的使用相关,用于进行相应的字符串的匹配和搜索相关<br><figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div></pre></td><td class="code"><pre><div class="line">import re</div></pre></td></tr></table></figure></p>
<p># </p>
</div>
<footer class="article-footer">
<a data-url="http://yoursite.com/2017/07/04/python基本数据结构和底层实现原理/" data-id="cj52eurb100025ahqhhxkrppc" class="article-share-link">Share</a>
</footer>
</div>
</article>
<article id="post-python-Redis的pub-sub相关" class="article article-type-post" itemscope itemprop="blogPost">
<div class="article-meta">
<a href="/2017/07/03/python-Redis的pub-sub相关/" class="article-date">
<time datetime="2017-07-03T11:40:13.000Z" itemprop="datePublished">2017-07-03</time>
</a>
</div>
<div class="article-inner">
<header class="article-header">
<h1 itemprop="name">
<a class="article-title" href="/2017/07/03/python-Redis的pub-sub相关/">python Redis的pub/sub相关</a>
</h1>
</header>
<div class="article-entry" itemprop="articleBody">
<h3 id="redis简介"><a href="#redis简介" class="headerlink" title="redis简介"></a>redis简介</h3><p> 它是一个速度很快的内存中的非关系的数据库(NoSQL),可以存储键与5种数据结构之间的映射,分别为string,list,set,hash,zset.<br> 它可以作为缓存和消息中间件<br> 它支持事务,订阅发布,LUA脚本,过期自动删除key, 内存回收,自动故障转移</p>
<h3 id="linux下的redis的安装"><a href="#linux下的redis的安装" class="headerlink" title="linux下的redis的安装"></a>linux下的redis的安装</h3><p> redis是一个服务端和客户端的模型,需要分别进行安装</p>
<ol>
<li><p><a href="https://github.com/antirez/redis" target="_blank" rel="external">redis-server</a>服务端的安装,默认情况下安装后会成为开机自启动的service,默认的主机名为localhost,端口号为6379</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div></pre></td><td class="code"><pre><div class="line">sudo apt-get install redis-server</div></pre></td></tr></table></figure>
</li>
<li><p>python支持的<a href="https://github.com/andymccurdy/redis-py" target="_blank" rel="external">redis-py</a>客户端安装</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div></pre></td><td class="code"><pre><div class="line">sudo pip install redis</div></pre></td></tr></table></figure>
</li>
<li><p>Redis 由四个可执行文件:redis-benchmark、redis-cli、redis-server、redis-stat 这四个文件,加上一个redis.conf就构成了整个redis的最终可用包.</p>
</li>
</ol>
<p> 可以通过redis-cli来进行相应的调试,用于模拟客户端的操作,在实际使用的过程中,服务端有个默认的同时连接客户端最大数量限制.所以在不用时,需要断开连接.</p>
<h3 id="Redis的发布订阅Pub-sub相关"><a href="#Redis的发布订阅Pub-sub相关" class="headerlink" title="Redis的发布订阅Pub/sub相关"></a>Redis的发布订阅Pub/sub相关</h3><ul>
<li><p>Redis 发布订阅(pub/sub)是一种消息通信模式:发送者(pub)发送消息,订阅者(sub)接收消息。Redis客户端可以订阅任意数量的频道,这样极大的解耦了消息的传输方式.</p>
</li>
<li><p>发布消息端只需要将相应的消息publish至相应的管道(具有唯一名来进行标识不同的管道)</p>
</li>
<li><p>订阅消息端只需要订阅相应的管道即可,只要一旦有消息存在,即可进行获取,通常用于多路数据分发和广播的场景中.
</p>
<h3 id="创建发布类"><a href="#创建发布类" class="headerlink" title="创建发布类"></a>创建发布类</h3><figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div><div class="line">11</div><div class="line">12</div><div class="line">13</div><div class="line">14</div></pre></td><td class="code"><pre><div class="line">import Threading</div><div class="line">import redis</div><div class="line"></div><div class="line">class MyPublisher(object):</div><div class="line"></div><div class="line"> def __init__(self, channels, data, host="localhost", port=6379):</div><div class="line"> self.channels = channels</div><div class="line"> self.publisher = redis.Redis(host=host, port=port)</div><div class="line"> self.task = Threading.Thread(target=pub_data,args=(data))</div><div class="line"></div><div class="line"> def pub_data(self, data):</div><div class="line"> if self.channels is not None:</div><div class="line"> map(lambda x: self.publisher.publish(*x),</div><div class="line"> zip(self.channels, len(self.channels) * [data]))</div></pre></td></tr></table></figure>
</li>
</ul>
<h3 id="创建订阅类"><a href="#创建订阅类" class="headerlink" title="创建订阅类"></a>创建订阅类</h3><figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div><div class="line">11</div><div class="line">12</div><div class="line">13</div><div class="line">14</div><div class="line">15</div><div class="line">16</div><div class="line">17</div><div class="line">18</div><div class="line">19</div><div class="line">20</div><div class="line">21</div><div class="line">22</div><div class="line">23</div><div class="line">24</div><div class="line">25</div><div class="line">26</div><div class="line">27</div><div class="line">28</div><div class="line">29</div><div class="line">30</div><div class="line">31</div><div class="line">32</div><div class="line">33</div><div class="line">34</div><div class="line">35</div><div class="line">36</div><div class="line">37</div><div class="line">38</div><div class="line">39</div><div class="line">40</div><div class="line">41</div><div class="line">42</div><div class="line">43</div><div class="line">44</div><div class="line">45</div><div class="line">46</div><div class="line">47</div><div class="line">48</div><div class="line">49</div><div class="line">50</div><div class="line">51</div><div class="line">52</div><div class="line">53</div><div class="line">54</div><div class="line">55</div></pre></td><td class="code"><pre><div class="line">import time</div><div class="line">import redis</div><div class="line">from cStringIO import StringIO</div><div class="line"></div><div class="line">class MySubscriber(object):</div><div class="line"> def __init__(self, channels, host="localhost", port=6379):</div><div class="line"> self.channel = channel</div><div class="line"> self.task = None</div><div class="line"> self.sub = None</div><div class="line"> self.ret = StringIO()</div><div class="line"> self.redis = redis.Redis(host=host, port=port)</div><div class="line"> self.stop_flag = False</div><div class="line"></div><div class="line"> def start_subscribe(self):</div><div class="line"> self.sub = self.redis.pubsub()</div><div class="line"> self.sub.subscribe(self.channel)</div><div class="line"> self.task = threading.Thread(target=self.sud_data, args=())</div><div class="line"></div><div class="line"> def __enter__(self):</div><div class="line"> self.start_subscribe()</div><div class="line"> return self</div><div class="line"> </div><div class="line"> def stop_subscribe(self):</div><div class="line"> self.ret.close()</div><div class="line"> self.sub.unsubscribe()</div><div class="line"> # close client connection to avoid max file descripter</div><div class="line"> self.sub.close()</div><div class="line"></div><div class="line"> def __exit__(self, exc_type, exc_val, exc_tb):</div><div class="line"> self.stop_subscribe()</div><div class="line"></div><div class="line"> def pub_data(self):</div><div class="line"> while True:</div><div class="line"> message = self.sub.get_message()</div><div class="line"> captured = False</div><div class="line"></div><div class="line"> if self.filters is not None:</div><div class="line"> for _filter in self.filters:</div><div class="line"> if _filter not in message:</div><div class="line"> continue</div><div class="line"> else:</div><div class="line"> captured = True</div><div class="line"> break</div><div class="line"></div><div class="line"> if not captured and self.filters is not None:</div><div class="line"> continue</div><div class="line"></div><div class="line"> if message and message['data'] != 1:</div><div class="line"> self.ret.write(message['data'])</div><div class="line"> if self.stop_flag:</div><div class="line"> break</div><div class="line"> time.sleep(0.001) </div><div class="line"></div><div class="line"> def get_data(self):</div><div class="line"> return self.ret.getvalue().decode("utf-8", errors="replace")</div></pre></td></tr></table></figure>
<h3 id="发布订阅测试用例"><a href="#发布订阅测试用例" class="headerlink" title="发布订阅测试用例"></a>发布订阅测试用例</h3><figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div></pre></td><td class="code"><pre><div class="line">import time</div><div class="line"> pub = MyPublisher(["TEST_DEMO"],"hello world")</div><div class="line"> time.sleep(5)</div><div class="line"> # 可创建多个客户端订阅相应的管道,可以同时接受同一份数据</div><div class="line"> sub = MySubscriber(["TEST_DEMO"])</div><div class="line"> with sub as s:</div><div class="line"> print(sub.get_data())</div></pre></td></tr></table></figure>
<h3 id="redis的单例模式"><a href="#redis的单例模式" class="headerlink" title="redis的单例模式"></a>redis的单例模式</h3><p> 为了减少系统资源的消耗,以及处理的数据并不是特别实时大量的情况下,大多采用单例的redis实例.只进行一次实例化.<br><figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div><div class="line">11</div><div class="line">12</div><div class="line">13</div><div class="line">14</div><div class="line">15</div><div class="line">16</div><div class="line">17</div><div class="line">18</div><div class="line">19</div><div class="line">20</div><div class="line">21</div></pre></td><td class="code"><pre><div class="line">class RedisSingleton(object):</div><div class="line"> instance = None</div><div class="line"> mutex = threading.Lock()</div><div class="line"></div><div class="line"> def __init__(self, host, port):</div><div class="line"> self.__redis = redis.Redis(host=host, port=port)</div><div class="line"></div><div class="line"> @staticmethod</div><div class="line"> def get_instance(host, port):</div><div class="line"></div><div class="line"> if (RedisSingleton.instance == None):</div><div class="line"> RedisSingleton.mutex.acquire()</div><div class="line"> if (RedisSingleton.instance == None):</div><div class="line"> RedisSingleton.instance = RedisSingleton(host, port)</div><div class="line"> RedisSingleton.mutex.release()</div><div class="line"></div><div class="line"> return RedisSingleton.instance</div><div class="line"></div><div class="line"> @property</div><div class="line"> def get_redis_instance(self):</div><div class="line"> return self.__redis</div></pre></td></tr></table></figure></p>
</div>
<footer class="article-footer">
<a data-url="http://yoursite.com/2017/07/03/python-Redis的pub-sub相关/" data-id="cj52eurb400045ahqklwohio8" class="article-share-link">Share</a>
</footer>
</div>
</article>
<article id="post-python-编码规范" class="article article-type-post" itemscope itemprop="blogPost">
<div class="article-meta">
<a href="/2017/07/03/python-编码规范/" class="article-date">
<time datetime="2017-07-03T05:44:48.000Z" itemprop="datePublished">2017-07-03</time>
</a>
</div>
<div class="article-inner">
<header class="article-header">
<h1 itemprop="name">
<a class="article-title" href="/2017/07/03/python-编码规范/">python_编码规范</a>
</h1>
</header>
<div class="article-entry" itemprop="articleBody">
<h3 id="禁用分号"><a href="#禁用分号" class="headerlink" title="禁用分号"></a>禁用分号</h3><ol>
<li>每行的表达式结尾禁止使用分号</li>
</ol>
<h3 id="缩进Indentation"><a href="#缩进Indentation" class="headerlink" title="缩进Indentation"></a>缩进Indentation</h3><ol>
<li>代码以<code>4个空格</code>来进行缩进,禁止混合使用空格和tab,除非进行了相应的配置</li>
<li>每个语句占一行</li>
</ol>
<h3 id="每行不超过80个字符"><a href="#每行不超过80个字符" class="headerlink" title="每行不超过80个字符"></a>每行不超过80个字符</h3><ol>
<li>除去长的模块导入语句和注释里的URL,Python会将<code>圆括号, 中括号和花括号中的行</code>隐式的连接起来</li>
<li>注意与使用反斜线的区分,主要用于不能进行自行连接的多行操作,例如with和assert</li>
</ol>
<h3 id="二进制运算符可以位于段行前或者后"><a href="#二进制运算符可以位于段行前或者后" class="headerlink" title="二进制运算符可以位于段行前或者后"></a>二进制运算符可以位于段行前或者后</h3><h3 id="空行"><a href="#空行" class="headerlink" title="空行"></a>空行</h3><ol>
<li>顶级定义,即顶级函数和类定义之间空两行</li>
<li>类内部的函数定义空一行</li>
<li>函数内部使用空行来进行相应的逻辑分割</li>
</ol>
<h3 id="空格"><a href="#空格" class="headerlink" title="空格"></a>空格</h3><ol>
<li>括号内没有空格</li>
<li>在逗号,冒号和分号前无空格,必须加在符号后面</li>
<li>参数列表, 索引或切片的左括号前不应加空格.</li>
<li>在<code>二元操作符</code>两边都加上一个空格</li>
<li>当’=’用于指示关键字参数或默认参数值时, 不要在其两侧使用空格.</li>
<li>不要用空格来垂直对齐多行间的标记</li>
</ol>
<h3 id="`-`的作用"><a href="#`-`的作用" class="headerlink" title="`#!`的作用"></a>`#!`的作用</h3><ol>
<li>类Unix操作系统的程序载入器会分析#!后的内容, 将这些内容作为解释器指令, 并调用该指令, 并将载有Shebang的文件路径作为该解释器的参数.</li>
</ol>
<h3 id="导入模块import"><a href="#导入模块import" class="headerlink" title="导入模块import"></a>导入模块import</h3><ol>
<li>不同模块分行进行导入</li>
<li>导入需要放置于文件说明前,导入次序为:标准模块,第三方模块,自定义模块</li>
<li>推荐使用绝对导入,支持相对路径导入(python3已经废弃)</li>
<li>尽量避免通配符*导入</li>
</ol>
<h3 id="字符串支持单引号和双引号"><a href="#字符串支持单引号和双引号" class="headerlink" title="字符串支持单引号和双引号"></a>字符串支持单引号和双引号</h3><h3 id="使用英文及时跟新注释comments,主要是块注释和行内注释,以及文档注释docstring"><a href="#使用英文及时跟新注释comments,主要是块注释和行内注释,以及文档注释docstring" class="headerlink" title="使用英文及时跟新注释comments,主要是块注释和行内注释,以及文档注释docstring"></a>使用英文及时跟新注释comments,主要是块注释和行内注释,以及文档注释docstring</h3><h3 id="命名规则name"><a href="#命名规则name" class="headerlink" title="命名规则name"></a>命名规则name</h3><ol>
<li>变量名应该反映的是使用意义usage,而不是其实现过程</li>
<li>类名采样CapWords的命名规则,使用名词,表示抽象的集合</li>
<li>用单下划线(_)开头表示模块变量或函数是protected的(使用import * from 时不会导入相应的变量和函数)</li>
<li>用双下划线(__)开头的实例变量或方法表示类内私有</li>
<li>双下划线开头并结尾的名称具有python内置的特殊含义,例如<code>__init__,__name__,__all__</code></li>
<li>函数命名一般采用动词表示完成的功能简写,词间用下划线分割,<code>且一个函数完成一个功能</code></li>
<li>避免使用单字符进行命名操作</li>
</ol>
<h3 id="main函数"><a href="#main函数" class="headerlink" title="main函数"></a>main函数</h3><p>一个模块中的主要执行部分,通常用于进行相应的单元测试<br><figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div></pre></td><td class="code"><pre><div class="line">if __name__ == "__main__":</div><div class="line"> main()</div></pre></td></tr></table></figure></p>
<h3 id="模块和包和库的区别"><a href="#模块和包和库的区别" class="headerlink" title="模块和包和库的区别"></a>模块和包和库的区别</h3><ol>
<li>模块<code>module</code>: 即一个.py文件,包含相应的组织代码</li>
<li>包<code>package</code>: 即一个有层次的文件目录,一定存在一个<strong>inin</strong>文件,以及其他的模块和子包</li>
<li>库<code>lib</code>: python库是参考其它编程语言的说法,就是指python中的完成一定功能的代码集合,供用户使用的代码组合。在python中是包和模块的形式</li>
</ol>
<h3 id="字符串格式化-与format"><a href="#字符串格式化-与format" class="headerlink" title="字符串格式化 %与format"></a>字符串格式化 <code>%与format</code></h3><figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div></pre></td><td class="code"><pre><div class="line">x = '%s, %s!' % (imperative, expletive)</div><div class="line">x = '{}, {}!'.format(imperative, expletive)</div></pre></td></tr></table></figure>
<h3 id="类继承"><a href="#类继承" class="headerlink" title="类继承"></a>类继承</h3><ol>
<li>如果一个类不继承自其它类, 就显式的从object继承(新式类). 嵌套类也一样</li>
<li>类的多重继承:如果多个类具有相同的方法,则会以第一个类的方法为子类所使用的方法,djando rest内的各个类的继承关系</li>
<li>类是一切事物的抽象,包含__init__用于进行实例的初始化操作,可以存在一些@property和@staticmethod等特殊的语法糖</li>
<li>双下划线开头的变量或方法为私有变量,只能在类的内部使用</li>
<li>类方法定义必须包含的第一个参数是self</li>
<li>类的专用方法<figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div></pre></td><td class="code"><pre><div class="line">__init__ 构造函数,在生成对象时调用</div><div class="line">__del__ 析构函数,释放对象时使用,通常进行相关的清理操作</div><div class="line">__repr__ 打印,转换</div><div class="line">__setitem__按照索引赋值</div><div class="line">__getitem__按照索引获取值</div><div class="line">__len__获得长度</div><div class="line">__cmp__比较运算</div><div class="line">__call__函数调用</div></pre></td></tr></table></figure>
</li>
</ol>
</div>
<footer class="article-footer">
<a data-url="http://yoursite.com/2017/07/03/python-编码规范/" data-id="cj52eurb300035ahq0c4juvtq" class="article-share-link">Share</a>
</footer>
</div>
</article>
</section>
<aside id="sidebar">
<div class="widget-wrap">
<h3 class="widget-title">Archives</h3>
<div class="widget">
<ul class="archive-list"><li class="archive-list-item"><a class="archive-list-link" href="/archives/2017/07/">July 2017</a></li></ul>
</div>
</div>
<div class="widget-wrap">
<h3 class="widget-title">Recent Posts</h3>
<div class="widget">
<ul>
<li>
<a href="/2017/07/13/python-参数传递方式/">python_参数传递方式</a>
</li>
<li>
<a href="/2017/07/07/python-迭代器/">python-迭代器</a>
</li>
<li>
<a href="/2017/07/07/go-json解码和执行外部脚本/">go-json解码和执行外部脚本</a>
</li>
<li>
<a href="/2017/07/04/python基本数据结构和底层实现原理/">python基本数据结构和底层实现原理</a>
</li>
<li>
<a href="/2017/07/03/python-Redis的pub-sub相关/">python Redis的pub/sub相关</a>
</li>
</ul>
</div>
</div>
</aside>
</div>
<footer id="footer">
<div class="outer">
<div id="footer-info" class="inner">
© 2017 aliyarly<br>
Powered by <a href="http://hexo.io/" target="_blank">Hexo</a>
</div>
</div>
</footer>
</div>
<nav id="mobile-nav">
<a href="/" class="mobile-nav-link">Home</a>
<a href="/archives" class="mobile-nav-link">Archives</a>
</nav>
<script src="//ajax.googleapis.com/ajax/libs/jquery/2.0.3/jquery.min.js"></script>
<link rel="stylesheet" href="/fancybox/jquery.fancybox.css">
<script src="/fancybox/jquery.fancybox.pack.js"></script>
<script src="/js/script.js"></script>
</div>
</body>
</html>