首页 > 代码库 > 234234

234234

<div id="article_details" class="details">    <div class="article_title">            <span class="ico ico_type_Original"></span>    <h1>        <span class="link_title"><a href="/fgf00/article/details/52098926">        Python(二)字符串操作、列表字典及深浅拷贝等                    </a></span>    </h1></div>           <div class="article_manage clearfix">        <div class="article_l">            <span class="link_categories">            标签:              <a href="http://www.csdn.net/tag/python" target="_blank" onclick="_gaq.push([‘_trackEvent‘,‘function‘, ‘onclick‘, ‘blog_articles_tag‘]);">python</a><a href="http://www.csdn.net/tag/%e5%ad%97%e7%ac%a6%e4%b8%b2" target="_blank" onclick="_gaq.push([‘_trackEvent‘,‘function‘, ‘onclick‘, ‘blog_articles_tag‘]);">字符串</a><a href="http://www.csdn.net/tag/%e5%88%97%e8%a1%a8" target="_blank" onclick="_gaq.push([‘_trackEvent‘,‘function‘, ‘onclick‘, ‘blog_articles_tag‘]);">列表</a><a href="http://www.csdn.net/tag/%e5%ad%97%e5%85%b8" target="_blank" onclick="_gaq.push([‘_trackEvent‘,‘function‘, ‘onclick‘, ‘blog_articles_tag‘]);">字典</a>            </span>        </div>        <div class="article_r">            <span class="link_postdate">2016-08-02 23:02</span>            <span class="link_view" title="阅读次数">648人阅读</span>            <span class="link_comments" title="评论次数"> <a href="#comments" onclick="_gaq.push([‘_trackEvent‘,‘function‘, ‘onclick‘, ‘blog_articles_pinglun‘])">评论</a>(0)</span>            <span class="link_collect tracking-ad" data-mod="popu_171"> <a href="javascript:void(0);" onclick="javascript:collectArticle(‘Python(%e4%ba%8c)%e5%ad%97%e7%ac%a6%e4%b8%b2%e6%93%8d%e4%bd%9c%e3%80%81%e5%88%97%e8%a1%a8%e5%ad%97%e5%85%b8%e5%8f%8a%e6%b7%b1%e6%b5%85%e6%8b%b7%e8%b4%9d%e7%ad%89‘,‘52098926‘);return false;" title="收藏" target="_blank">收藏</a></span>             <span class="link_report"> <a href="#report" onclick="javascript:report(52098926,2);return false;" title="举报">举报</a></span>        </div>    </div>    <div class="embody" style="display:none" id="embody">        <span class="embody_t">本文章已收录于:</span>        <div class="embody_c" id="lib" value="{&quot;err&quot;:0,&quot;msg&quot;:&quot;ok&quot;,&quot;data&quot;:[]}"></div>    </div>    <style type="text/css">                    .embody{                padding:10px 10px 10px;                margin:0 -20px;                border-bottom:solid 1px #ededed;                            }            .embody_b{                margin:0 ;                padding:10px 0;            }            .embody .embody_t,.embody .embody_c{                display: inline-block;                margin-right:10px;            }            .embody_t{                font-size: 12px;                color:#999;            }            .embody_c{                font-size: 12px;            }            .embody_c img,.embody_c em{                display: inline-block;                vertical-align: middle;                           }             .embody_c img{                               width:30px;                height:30px;            }            .embody_c em{                margin: 0 20px 0 10px;                color:#333;                font-style: normal;            }    </style>    <script type="text/javascript">        $(function () {            try            {                var lib = eval("("+$("#lib").attr("value")+")");                var html = "";                if (lib.err == 0) {                    $.each(lib.data, function (i) {                        var obj = lib.data[i];                        //html += ‘<img src="http://www.mamicode.com/‘ + obj.logo + ‘"/>‘ + obj.name + "&nbsp;&nbsp;";                        html +=  <a href="http://www.mamicode.com/ + obj.url + " target="_blank">;                        html +=  <img src="http://www.mamicode.com/ + obj.logo + ">;                        html +=  <em><b> + obj.name + </b></em>;                        html +=  </a>;                    });                    if (html != "") {                        setTimeout(function () {                            $("#lib").html(html);                                                  $("#embody").show();                        }, 100);                    }                }                  } catch (err)            { }                    });    </script>      <div class="category clearfix">        <div class="category_l">           <img src="http://static.blog.csdn.net/images/category_icon.jpg">            <span>分类:</span>        </div>        <div class="category_r">                    <label onclick="GetCategoryArticles(‘5985977‘,‘fgf00‘,‘top‘,‘52098926‘);">                        <span onclick="_gaq.push([‘_trackEvent‘,‘function‘, ‘onclick‘, ‘blog_articles_fenlei‘]);">Python开发<em>(24)</em></span>                      <img class="arrow-down" src="http://static.blog.csdn.net/images/arrow_triangle _down.jpg" style="display:inline;">                      <img class="arrow-up" src="http://static.blog.csdn.net/images/arrow_triangle_up.jpg" style="display:none;">                        <div class="subItem">                            <div class="subItem_t"><a href="http://blog.csdn.net/fgf00/article/category/5985977" target="_blank">作者同类文章</a><i class="J_close">X</i></div>                            <ul class="subItem_l" id="top_5985977">                                                        </ul>                        </div>                    </label>                            </div>    </div>    <script type="text/javascript" src="http://static.blog.csdn.net/scripts/category.js"></script>             <div style="clear:both"></div><div style="border:solid 1px #ccc; background:#eee; float:left; min-width:200px;padding:4px 10px;"><p style="text-align:right;margin:0;"><span style="float:left;">目录<a href="#" title="系统根据文章中H1到H6标签自动生成文章目录">(?)</a></span><a href="#" onclick="javascript:return openct(this);" title="展开">[+]</a></p><ol style="display:none;margin-left:14px;padding-left:14px;line-height:160%;"><li><a href="#t0">目录</a></li><li><a href="#t1">一模块初识</a></li><li><a href="#t2">二pyc是什么</a></li><li><a href="#t3">三数据类型初识 </a></li><li><a href="#t4">四字符串操作</a></li><li><a href="#t5">五列表元组操作</a></li><li><a href="#t6">六字典操作</a></li><li><a href="#t7">七深copy和浅copy</a></li></ol></div><div style="clear:both"></div><div id="article_content" class="article_content">        <div class="markdown_views"><h3 id="目录"><a name="t0"></a><strong>目录</strong></h3><p>模块初识 <br>.pyc是什么? <br>数据类型初识 <br>字符串操作 <br>列表、元组操作 <br>字典操作 <br>深copy和浅copy</p><h3 id="一模块初识"><a name="t1"></a><strong>一、模块初识</strong></h3><p><a href="http://lib.csdn.net/base/python" class="replace_word" title="Python知识库" target="_blank" style="color:#df3434; font-weight:bold;">Python</a>的强大之处在于他有非常丰富和强大的标准库和第三方库。 <br>    一般标准库 在 Lib 目录 <br>    第三方库:在 site-packages</p><p><strong>sys模块</strong>(python解释器的sys模块,用c语音写的,Lib目录下没有sys.py)</p><pre class="prettyprint" name="code"><code class="hljs mel has-numbering">sys.path  # <span class="hljs-keyword">python</span>调用模块时,查找的<span class="hljs-keyword">python</span>全局环境变量sys.argv  # 参数,类似shell脚本中的的<span class="hljs-variable">$1</span><span class="hljs-variable">$2</span><span class="hljs-variable">$3</span></code><ul class="pre-numbering"><li>1</li><li>2</li></ul><div class="save_code tracking-ad" data-mod="popu_249"><a href="javascript:;" target="_blank"><img src="http://static.blog.csdn.net/images/save_snippets.png"></a></div><ul class="pre-numbering"><li>1</li><li>2</li></ul></pre><pre class="prettyprint" name="code"><code class="hljs python has-numbering"><span class="hljs-comment">#!/usr/bin/env python</span><span class="hljs-comment">#coding=utf-8</span><span class="hljs-keyword">import</span> sysprint(sys.argv)<span class="hljs-comment">#输出</span>$ python test.py helo world[<span class="hljs-string">‘test.py‘</span>, <span class="hljs-string">‘helo‘</span>, <span class="hljs-string">‘world‘</span>]  <span class="hljs-comment"># 把执行脚本时传递的参数获取到了</span></code><ul class="pre-numbering"><li>1</li><li>2</li><li>3</li><li>4</li><li>5</li><li>6</li><li>7</li><li>8</li><li>9</li><li>10</li></ul><div class="save_code tracking-ad" data-mod="popu_249"><a href="javascript:;" target="_blank"><img src="http://static.blog.csdn.net/images/save_snippets.png"></a></div><ul class="pre-numbering"><li>1</li><li>2</li><li>3</li><li>4</li><li>5</li><li>6</li><li>7</li><li>8</li><li>9</li><li>10</li></ul></pre><p><strong>os模块</strong></p><pre class="prettyprint" name="code"><code class="hljs perl has-numbering">os.<span class="hljs-keyword">system</span>(<span class="hljs-string">‘dir‘</span>)  <span class="hljs-comment"># 调用系统命令,不保存结果</span><span class="hljs-comment"># 结果直接输出在屏幕上,返回结果只是命令执行状态</span><span class="hljs-comment"># 保存结果使用os.popen()</span>cmd = os.popen(<span class="hljs-string">‘dir‘</span>): <span class="hljs-keyword">print</span>(cmd)  <span class="hljs-comment"># 打印的是内存地址</span>cmd_res = os.popen(<span class="hljs-string">‘dir‘</span>).<span class="hljs-keyword">read</span>()<span class="hljs-keyword">print</span>(cmd_res)  <span class="hljs-comment"># 打印命令结果</span>os.<span class="hljs-keyword">mkdir</span>(<span class="hljs-string">‘new_dir‘</span>)  <span class="hljs-comment"># 创建目录</span></code><ul class="pre-numbering"><li>1</li><li>2</li><li>3</li><li>4</li><li>5</li><li>6</li><li>7</li><li>8</li><li>9</li><li>10</li><li>11</li></ul><div class="save_code tracking-ad" data-mod="popu_249" style="display: none;"><a href="javascript:;" target="_blank"><img src="http://static.blog.csdn.net/images/save_snippets.png"></a></div><ul class="pre-numbering"><li>1</li><li>2</li><li>3</li><li>4</li><li>5</li><li>6</li><li>7</li><li>8</li><li>9</li><li>10</li><li>11</li></ul></pre><p><strong>结合一下</strong> </p><pre class="prettyprint" name="code"><code class="hljs lua has-numbering">import <span class="hljs-built_in">os</span>,sys<span class="hljs-built_in">os</span>.system(<span class="hljs-string">‘‘</span>.join(sys.argv[<span class="hljs-number">1</span>:]))  # 把用户的输入的参数当作一条命令交给<span class="hljs-built_in">os</span>.system来执行</code><ul class="pre-numbering"><li>1</li><li>2</li></ul><div class="save_code tracking-ad" data-mod="popu_249"><a href="javascript:;" target="_blank"><img src="http://static.blog.csdn.net/images/save_snippets.png"></a></div><ul class="pre-numbering"><li>1</li><li>2</li></ul></pre><p>import 导入模块 <br>先查找当前目录,当前目录没有,再去环境变量中找</p><h3 id="二pyc是什么"><a name="t2"></a><strong>二、.pyc是什么?</strong></h3><p>python是解释型语言,那么生成的*.pyc文件是什么呢?c应该是compiled的缩写才对啊! <br>一些解释型语言也可以通过解释器的优化来在对程序做出翻译时对整个程序做出优化,从而在效率上接近编译型语言。 <br>此外,随着<a href="http://lib.csdn.net/base/javase" class="replace_word" title="Java SE知识库" target="_blank" style="color:#df3434; font-weight:bold;">Java</a>等基于虚拟机的语言的兴起,我们又不能把语言纯粹地分成解释型和编译型这两种。 <br>用Java来举例,Java首先是通过编译器编译成字节码文件,然后在运行时通过解释器给解释成机器文件。所以我们说Java是一种先编译后解释的语言。</p><p>其实Python和Java/C#一样,也是一门基于虚拟机的语言 <br><strong>简述Python的运行过程</strong> <br>当python程序运行时,编译的结果则是保存在位于内存中的PyCodeObject中,当Python程序运行结束时,Python解释器则将PyCodeObject写回到pyc文件中。 <br>当python程序第二次运行时,首先程序会在硬盘中寻找pyc文件,如果找到,则直接载入,否则就重复上面的过程。 <br>判断更新时间,执行py还是pyc。</p><pre><code>3.x : .pyc在__pycache__目录,无py文件,导入会报错2.x :.pyc在当前目录,无py文件,pyc可以导入使用</code></pre><p>说pyc文件其实是PyCodeObject的一种持久化保存方式。</p><h3 id="三数据类型初识"><a name="t3"></a><strong>三、数据类型初识 </strong></h3><p><strong>1、数字</strong></p><ul><li>int(整型) <br>  在32位机器上,整数的位数为32位,取值范围为-2**31~2**31-1,即-2147483648~2147483647 <br>  在64位系统上,整数的位数为64位,取值范围为-2**63~2**63-1,即-9223372036854775808~9223372036854775807 <br>  这也是为什么32位系统内存最大为4G的原因。4G=4*1024M*1024k*1024-1 = 2147483647-(-2147483648)</li><li>long(长整型) <br>从Python2.2起,如果整数发生溢出,Python会自动将整数数据转换为长整数 <br>python3 已经不区分int和long</li></ul><pre class="prettyprint" name="code"><code class="hljs haskell has-numbering"><span class="hljs-preprocessor"># Python 2.x版本</span><span class="hljs-typedef"><span class="hljs-keyword">type</span><span class="hljs-container">(2**32)</span> &gt;&gt; int</span><span class="hljs-typedef"><span class="hljs-keyword">type</span><span class="hljs-container">(2**64)</span> &gt;&gt; long</span></code><ul class="pre-numbering"><li>1</li><li>2</li><li>3</li></ul><div class="save_code tracking-ad" data-mod="popu_249"><a href="javascript:;" target="_blank"><img src="http://static.blog.csdn.net/images/save_snippets.png"></a></div><ul class="pre-numbering"><li>1</li><li>2</li><li>3</li></ul></pre><ul><li>float(浮点型) <br>浮点数用来处理实数,即带有小数的数字。 <br>浮点数是属于有理数中某特定子集的数的数字表示,小数包括有理数和无理数。 <br>所以浮点数一定是小数,小数不一定是浮点数。 <br>浮点计算是指浮点数参与的运算,这种运算通常伴随着因为无法精确表示而进行的近似或舍入。</li><li>复数 <br>由实数部分和虚数部分组成,一般形式为x+yj,其中的x是复数的实数部分,y是复数的虚数部分,这里的x和y都是实数。</li></ul><p><font color="red">底层加减乘除是用的位运算。位移 “&lt;&lt;” “&gt;&gt;” ,比除法快</font></p><pre class="prettyprint" name="code"><code class="hljs python has-numbering"><span class="hljs-number">1</span>位除<span class="hljs-number">2</span>,移<span class="hljs-number">2</span>位除<span class="hljs-number">2</span>**<span class="hljs-number">2</span> 取整<span class="hljs-prompt">&gt;&gt;&gt; </span><span class="hljs-number">64</span> &gt;&gt; <span class="hljs-number">3</span><span class="hljs-number">8</span></code><ul class="pre-numbering"><li>1</li><li>2</li><li>3</li></ul><div class="save_code tracking-ad" data-mod="popu_249"><a href="javascript:;" target="_blank"><img src="http://static.blog.csdn.net/images/save_snippets.png"></a></div><ul class="pre-numbering"><li>1</li><li>2</li><li>3</li></ul></pre><p><font color="red">三元运算:</font></p><pre class="prettyprint" name="code"><code class="hljs livecodeserver has-numbering"><span class="hljs-operator">a</span>,b,c = <span class="hljs-number">1</span>,<span class="hljs-number">3</span>,<span class="hljs-number">5</span>d = <span class="hljs-operator">a</span> <span class="hljs-keyword">if</span> <span class="hljs-operator">a</span> &gt; b <span class="hljs-keyword">else</span> c</code><ul class="pre-numbering"><li>1</li><li>2</li></ul><div class="save_code tracking-ad" data-mod="popu_249"><a href="javascript:;" target="_blank"><img src="http://static.blog.csdn.net/images/save_snippets.png"></a></div><ul class="pre-numbering"><li>1</li><li>2</li></ul></pre><p><strong>2、布尔值</strong></p><pre class="prettyprint" name="code"><code class="hljs mathematica has-numbering">    <span class="hljs-keyword">True</span>  <span class="hljs-keyword">False</span>    <span class="hljs-number">1</span>       <span class="hljs-number">0</span></code><ul class="pre-numbering"><li>1</li><li>2</li></ul><div class="save_code tracking-ad" data-mod="popu_249"><a href="javascript:;" target="_blank"><img src="http://static.blog.csdn.net/images/save_snippets.png"></a></div><ul class="pre-numbering"><li>1</li><li>2</li></ul></pre><p><strong>3、字符串</strong> <br>Python 3最重要的新特性大概是对文本和二进制数据做了更为清晰地区分。文本总是Unicode,由str类型表示,二进制数据由bytes类型表示。Python 3不会以任意隐式的方式混用str和butes,正因为此,python 3不能拼接字符串和字符包,也无法在字节包里搜索字符串,不能讲字符串传入参数为字节包的函数。 <br><strong>str 转为 bytes – encode</strong></p><pre class="prettyprint" name="code"><code class="hljs python has-numbering"><span class="hljs-prompt">&gt;&gt;&gt; </span><span class="hljs-string">"fgf"</span>.encode(<span class="hljs-string">‘utf-8‘</span>)<span class="hljs-string">b‘fgf‘</span><span class="hljs-prompt">&gt;&gt;&gt; </span><span class="hljs-string">"活着"</span>.encode(<span class="hljs-string">‘utf-8‘</span>)      <span class="hljs-comment"># utf-8编码转为二进制</span><span class="hljs-string">b‘\xe6\xb4\xbb\xe7\x9d\x80‘</span><span class="hljs-comment"># python 2.x 不指定编码,则使用系统编码</span><span class="hljs-comment"># python 3.x 不指定编码,则使用utf-8</span></code><ul class="pre-numbering"><li>1</li><li>2</li><li>3</li><li>4</li><li>5</li><li>6</li></ul><div class="save_code tracking-ad" data-mod="popu_249"><a href="javascript:;" target="_blank"><img src="http://static.blog.csdn.net/images/save_snippets.png"></a></div><ul class="pre-numbering"><li>1</li><li>2</li><li>3</li><li>4</li><li>5</li><li>6</li></ul></pre><p><strong>bytes 转为 str – decode</strong></p><pre class="prettyprint" name="code"><code class="hljs tex has-numbering">&gt;&gt;&gt; b‘<span class="hljs-command">\xe</span>6<span class="hljs-command">\xb</span>4<span class="hljs-command">\xbb</span><span class="hljs-command">\xe</span>7<span class="hljs-command">\x</span>9d<span class="hljs-command">\x</span>80‘.decode(‘utf-8‘)‘活着‘                          <span class="hljs-special">#</span> 二进制转为utf-8编码</code><ul class="pre-numbering"><li>1</li><li>2</li></ul><div class="save_code tracking-ad" data-mod="popu_249"><a href="javascript:;" target="_blank"><img src="http://static.blog.csdn.net/images/save_snippets.png"></a></div><ul class="pre-numbering"><li>1</li><li>2</li></ul></pre><p>python 数据传输,都是以二进制数据传。</p><p><strong>二进制和十六进制的转化</strong></p><p>十六进制:二进制每4位表示16进制的一位。对应关系如图</p><table><thead><tr>  <th>0</th>  <th>1</th>  <th>2</th>  <th>3</th>  <th>4</th>  <th>5</th>  <th>6</th>  <th>7</th>  <th>8</th>  <th>9</th>  <th>A</th>  <th>B</th>  <th>C</th>  <th>D</th>  <th>E</th>  <th>F</th></tr></thead><tbody><tr>  <td>0000</td>  <td>0001</td>  <td>0010</td>  <td>0011</td>  <td>0100</td>  <td>0101</td>  <td>0110</td>  <td>0111</td>  <td>1000</td>  <td>1001</td>  <td>1010</td>  <td>1011</td>  <td>1100</td>  <td>1101</td>  <td>1110</td>  <td>1111</td></tr></tbody></table><p>二进制转换成十六进制的方法是,取四合一法,即从二进制的小数点为分界点,向左(或向右)每四位取成一位</p><pre class="prettyprint" name="code"><code class="hljs bash has-numbering"><span class="hljs-number">1011</span> <span class="hljs-number">1001</span> <span class="hljs-number">1011</span> <span class="hljs-number">1001</span>  <span class="hljs-comment"># 二进制</span> v    v    v    v         V B    <span class="hljs-number">9</span>    B    <span class="hljs-number">9</span>    <span class="hljs-comment"># 十六进制</span></code><ul class="pre-numbering"><li>1</li><li>2</li><li>3</li></ul><div class="save_code tracking-ad" data-mod="popu_249"><a href="javascript:;" target="_blank"><img src="http://static.blog.csdn.net/images/save_snippets.png"></a></div><ul class="pre-numbering"><li>1</li><li>2</li><li>3</li></ul></pre><p>注意16进制的表示法,用字母H后缀表示,比如BH就表示16进制数11;也可以用0X前缀表示 <br>在向左(或向右)取四位时,取到最高位(最低位)如果无法凑足四位,就可以在小数点的最左边(或最右边)补0,进行换算</p><p>将十六进制转为二进制,一分四,即一个十六进制数分成四个二进制数,用四位二进制按权相加,最后得到二进制,小数点依旧就可以</p><pre class="prettyprint" name="code"><code class="hljs r has-numbering"> B    <span class="hljs-literal">F</span>    <span class="hljs-number">4</span> .  B    <span class="hljs-number">5</span>    <span class="hljs-comment"># 十六进制</span> v    v    v    v    v        V<span class="hljs-number">1011</span> <span class="hljs-number">1111</span> <span class="hljs-number">0100.1011</span> <span class="hljs-number">0101</span>  <span class="hljs-comment"># 二进制</span></code><ul class="pre-numbering"><li>1</li><li>2</li><li>3</li></ul><div class="save_code tracking-ad" data-mod="popu_249"><a href="javascript:;" target="_blank"><img src="http://static.blog.csdn.net/images/save_snippets.png"></a></div><ul class="pre-numbering"><li>1</li><li>2</li><li>3</li></ul></pre><p><strong>判断一个变量的类型</strong></p><pre class="prettyprint" name="code"><code class="hljs python has-numbering"><span class="hljs-prompt">&gt;&gt;&gt; </span>num = <span class="hljs-number">27</span><span class="hljs-prompt">&gt;&gt;&gt; </span>isinstance(num, str)    <span class="hljs-comment"># 判断变量类型</span><span class="hljs-keyword">False</span><span class="hljs-prompt">&gt;&gt;&gt; </span>type(num)               <span class="hljs-comment"># 获取变量类型</span>&lt;<span class="hljs-class"><span class="hljs-keyword">class</span><span class="hljs-title">int</span>&gt;</span></code><ul class="pre-numbering"><li>1</li><li>2</li><li>3</li><li>4</li><li>5</li></ul><div class="save_code tracking-ad" data-mod="popu_249"><a href="javascript:;" target="_blank"><img src="http://static.blog.csdn.net/images/save_snippets.png"></a></div><ul class="pre-numbering"><li>1</li><li>2</li><li>3</li><li>4</li><li>5</li></ul></pre><h3 id="四字符串操作"><a name="t4"></a><strong>四、字符串操作</strong></h3><ul><li>大小写处理</li></ul><pre class="prettyprint" name="code"><code class="hljs applescript has-numbering"><span class="hljs-property">name</span> = <span class="hljs-string">"fgf"</span><span class="hljs-property">name</span>.capitalize()           <span class="hljs-comment"># 首字母大写</span><span class="hljs-property">name</span>.lower()                <span class="hljs-comment"># 全小写</span><span class="hljs-property">name</span>.upper()                <span class="hljs-comment"># 全大写</span><span class="hljs-property">name</span>.swapcase()             <span class="hljs-comment"># 大小写转换</span></code><ul class="pre-numbering"><li>1</li><li>2</li><li>3</li><li>4</li><li>5</li></ul><div class="save_code tracking-ad" data-mod="popu_249"><a href="javascript:;" target="_blank"><img src="http://static.blog.csdn.net/images/save_snippets.png"></a></div><ul class="pre-numbering"><li>1</li><li>2</li><li>3</li><li>4</li><li>5</li></ul></pre><ul><li>字符串格式判断</li></ul><pre class="prettyprint" name="code"><code class="hljs avrasm has-numbering">name<span class="hljs-preprocessor">.isdigit</span>()              <span class="hljs-preprocessor"># 是不是整数</span>name<span class="hljs-preprocessor">.isidentifier</span>()         <span class="hljs-preprocessor"># 判断是不是合法的标识符</span>name<span class="hljs-preprocessor">.isalnum</span>()              <span class="hljs-preprocessor"># 是不是字母和数字,阿拉伯</span>name<span class="hljs-preprocessor">.isalpha</span>()              <span class="hljs-preprocessor"># 是不是字母</span>name<span class="hljs-preprocessor">.istitle</span>()              <span class="hljs-preprocessor"># 是否首字母大写</span>name<span class="hljs-preprocessor">.issupper</span>()             <span class="hljs-preprocessor"># 全大写</span>name<span class="hljs-preprocessor">.endswith</span>(<span class="hljs-string">"f"</span>)          <span class="hljs-preprocessor"># 是否以什么结尾</span>name<span class="hljs-preprocessor">.startswith</span>(<span class="hljs-string">"-"</span>)        <span class="hljs-preprocessor"># 是否以负号开头</span></code><ul class="pre-numbering"><li>1</li><li>2</li><li>3</li><li>4</li><li>5</li><li>6</li><li>7</li><li>8</li></ul><div class="save_code tracking-ad" data-mod="popu_249"><a href="javascript:;" target="_blank"><img src="http://static.blog.csdn.net/images/save_snippets.png"></a></div><ul class="pre-numbering"><li>1</li><li>2</li><li>3</li><li>4</li><li>5</li><li>6</li><li>7</li><li>8</li></ul></pre><ul><li>格式化输出</li></ul><pre class="prettyprint" name="code"><code class="hljs avrasm has-numbering">name<span class="hljs-preprocessor">.format</span>()               <span class="hljs-preprocessor"># 字符串格式化输出</span>name<span class="hljs-preprocessor">.center</span>(<span class="hljs-number">50</span>,<span class="hljs-string">"-"</span>)         <span class="hljs-preprocessor"># 打印50个字符,不够-补足</span>name<span class="hljs-preprocessor">.ljust</span>(<span class="hljs-number">50</span>,<span class="hljs-string">"*"</span>)          <span class="hljs-preprocessor"># 字符在左,空位*填充</span>name<span class="hljs-preprocessor">.rjust</span>(<span class="hljs-number">50</span>,<span class="hljs-string">"*"</span>)          <span class="hljs-preprocessor"># 字符在右,空位*填充</span><span class="hljs-string">"f\tgf"</span><span class="hljs-preprocessor">.expandtabs</span>(<span class="hljs-number">30</span>)      <span class="hljs-preprocessor"># 把tab转成多少个空格</span>name=<span class="hljs-string">"1"</span>name<span class="hljs-preprocessor">.zfill</span>(<span class="hljs-number">2</span>)               <span class="hljs-preprocessor"># 补位</span></code><ul class="pre-numbering"><li>1</li><li>2</li><li>3</li><li>4</li><li>5</li><li>6</li><li>7</li></ul><div class="save_code tracking-ad" data-mod="popu_249"><a href="javascript:;" target="_blank"><img src="http://static.blog.csdn.net/images/save_snippets.png"></a></div><ul class="pre-numbering"><li>1</li><li>2</li><li>3</li><li>4</li><li>5</li><li>6</li><li>7</li></ul></pre><ul><li>字符空格回车处理</li></ul><pre class="prettyprint" name="code"><code class="hljs applescript has-numbering"><span class="hljs-property">name</span> = <span class="hljs-string">"\n\n  fgf \n"</span><span class="hljs-property">name</span>.strip()                <span class="hljs-comment"># 去除空格回车tab</span><span class="hljs-property">name</span>.lstrip()               <span class="hljs-comment"># 去除左边空格回车tab</span><span class="hljs-property">name</span>.rstrip()               <span class="hljs-comment"># 去除右边空格回车tab</span></code><ul class="pre-numbering"><li>1</li><li>2</li><li>3</li><li>4</li></ul><div class="save_code tracking-ad" data-mod="popu_249"><a href="javascript:;" target="_blank"><img src="http://static.blog.csdn.net/images/save_snippets.png"></a></div><ul class="pre-numbering"><li>1</li><li>2</li><li>3</li><li>4</li></ul></pre><ul><li>字符串处理</li></ul><pre class="prettyprint" name="code"><code class="hljs avrasm has-numbering">name<span class="hljs-preprocessor">.split</span>()                <span class="hljs-preprocessor"># 切片</span><span class="hljs-string">"+"</span><span class="hljs-preprocessor">.join</span>([<span class="hljs-string">"1"</span>,<span class="hljs-string">"2"</span>,<span class="hljs-string">"3"</span>])     <span class="hljs-preprocessor"># 字符串拼接</span>name<span class="hljs-preprocessor">.count</span>(<span class="hljs-string">‘f‘</span>)             <span class="hljs-preprocessor"># 统计个数</span>name<span class="hljs-preprocessor">.find</span>(<span class="hljs-string">"gf"</span>)             <span class="hljs-preprocessor"># 找它的索引</span><span class="hljs-string">"fgf"</span><span class="hljs-preprocessor">.replace</span>(<span class="hljs-string">‘f‘</span>,<span class="hljs-string">‘F‘</span>,<span class="hljs-number">1</span>)    <span class="hljs-preprocessor"># 字符替换,几次</span></code><ul class="pre-numbering"><li>1</li><li>2</li><li>3</li><li>4</li><li>5</li></ul><div class="save_code tracking-ad" data-mod="popu_249"><a href="javascript:;" target="_blank"><img src="http://static.blog.csdn.net/images/save_snippets.png"></a></div><ul class="pre-numbering"><li>1</li><li>2</li><li>3</li><li>4</li><li>5</li></ul></pre><ul><li>其他</li></ul><pre class="prettyprint" name="code"><code class="hljs python has-numbering">                            <span class="hljs-comment"># 类似加密转化</span><span class="hljs-prompt">&gt;&gt;&gt; </span>p = str.maketrans(<span class="hljs-string">"cdef"</span>,<span class="hljs-string">"1234"</span>)<span class="hljs-prompt">&gt;&gt;&gt; </span>print(<span class="hljs-string">‘fgf‘</span>.translate(p))<span class="hljs-number">4</span>g4&gt;&gt;&gt;msg = <span class="hljs-string">‘‘‘fgf‘‘‘</span>&gt;&gt;&gt;name.splitlines(msg)     <span class="hljs-comment"># 以每行切片</span></code><ul class="pre-numbering"><li>1</li><li>2</li><li>3</li><li>4</li><li>5</li><li>6</li><li>7</li><li>8</li><li>9</li><li>10</li><li>11</li></ul><div class="save_code tracking-ad" data-mod="popu_249"><a href="javascript:;" target="_blank"><img src="http://static.blog.csdn.net/images/save_snippets.png"></a></div><ul class="pre-numbering"><li>1</li><li>2</li><li>3</li><li>4</li><li>5</li><li>6</li><li>7</li><li>8</li><li>9</li><li>10</li><li>11</li></ul></pre><h3 id="五列表元组操作"><a name="t5"></a><strong>五、列表、元组操作</strong></h3><p>列表</p><pre class="prettyprint" name="code"><code class="language-python hljs  has-numbering">命名规则“[]”    name = [<span class="hljs-string">"A"</span>,<span class="hljs-string">"B"</span>,<span class="hljs-string">"C"</span>,<span class="hljs-string">"D"</span>,<span class="hljs-string">"E"</span>]取值    print(name[<span class="hljs-number">0</span>], name[<span class="hljs-number">1</span>])     print(name[<span class="hljs-number">1</span>:<span class="hljs-number">3</span>])            <span class="hljs-comment"># 切片,顾头不顾尾</span>    name[-<span class="hljs-number">1</span>]                    <span class="hljs-comment"># 取最后一个</span>    <span class="hljs-comment"># name[-1:-3]               # 从左往右,这样取不到值</span>    name[-<span class="hljs-number">3</span>:-<span class="hljs-number">1</span>]                 <span class="hljs-comment"># 取倒数第三到最后一个</span>    name[-<span class="hljs-number">2</span>:]                   <span class="hljs-comment"># 取最后两个</span>添加:    names.append(<span class="hljs-string">""</span>)            <span class="hljs-comment"># 追加</span>    names.insert(<span class="hljs-number">1</span>,<span class="hljs-string">""</span>)          <span class="hljs-comment"># 插入哪写哪</span>修改:    names[<span class="hljs-number">2</span>] = <span class="hljs-string">""</span>               <span class="hljs-comment"># 修改</span>删除:    names.remove(<span class="hljs-string">"fgf"</span>)         <span class="hljs-comment"># 删第一个从左往右</span>    <span class="hljs-keyword">del</span> names[<span class="hljs-number">1</span>]    names.pop(<span class="hljs-number">1</span>)                <span class="hljs-comment"># 坐标为空则删最后一个</span>取下标:    names.index(<span class="hljs-string">"fgf"</span>)          <span class="hljs-comment"># 取下标</span>统计:    names.count(<span class="hljs-string">"fgf"</span>)          <span class="hljs-comment"># 统计</span>排序: <span class="hljs-comment"># 按ascii码排序,符号、数字、大写小写</span>    names.sort()                <span class="hljs-comment"># 排序</span>反转:    names.reverse()             <span class="hljs-comment"># 反转</span>清除列表:    names.clear()               <span class="hljs-comment"># 清空</span>扩充:    names2 = [<span class="hljs-number">1</span>,<span class="hljs-number">2</span>,<span class="hljs-number">3</span>,<span class="hljs-number">4</span>]    names.extend(name2)         <span class="hljs-comment"># 扩充</span>    <span class="hljs-keyword">del</span> names2  <span class="hljs-comment"># 删掉变量</span>遍历:    <span class="hljs-keyword">for</span> i <span class="hljs-keyword">in</span> names:             <span class="hljs-comment">#遍历列表</span>        <span class="hljs-keyword">print</span> i步长    range(<span class="hljs-number">1</span>,<span class="hljs-number">10</span>,<span class="hljs-number">2</span>)       names[<span class="hljs-number">0</span>:-<span class="hljs-number">1</span>:<span class="hljs-number">2</span>]  &lt;--&gt;  names(::<span class="hljs-number">2</span>)</code><ul class="pre-numbering"><li>1</li><li>2</li><li>3</li><li>4</li><li>5</li><li>6</li><li>7</li><li>8</li><li>9</li><li>10</li><li>11</li><li>12</li><li>13</li><li>14</li><li>15</li><li>16</li><li>17</li><li>18</li><li>19</li><li>20</li><li>21</li><li>22</li><li>23</li><li>24</li><li>25</li><li>26</li><li>27</li><li>28</li><li>29</li><li>30</li><li>31</li><li>32</li><li>33</li><li>34</li><li>35</li><li>36</li><li>37</li><li>38</li><li>39</li></ul><div class="save_code tracking-ad" data-mod="popu_249"><a href="javascript:;" target="_blank"><img src="http://static.blog.csdn.net/images/save_snippets.png"></a></div><ul class="pre-numbering"><li>1</li><li>2</li><li>3</li><li>4</li><li>5</li><li>6</li><li>7</li><li>8</li><li>9</li><li>10</li><li>11</li><li>12</li><li>13</li><li>14</li><li>15</li><li>16</li><li>17</li><li>18</li><li>19</li><li>20</li><li>21</li><li>22</li><li>23</li><li>24</li><li>25</li><li>26</li><li>27</li><li>28</li><li>29</li><li>30</li><li>31</li><li>32</li><li>33</li><li>34</li><li>35</li><li>36</li><li>37</li><li>38</li><li>39</li></ul></pre><p>元组 <br>元组():又称:只读列表 <br>    只有 count index 两个方法</p><h3 id="六字典操作"><a name="t6"></a><strong>六、字典操作</strong></h3><p>字典一种key - value 的数据类型 <br>语法:</p><pre class="prettyprint" name="code"><code class="hljs bash has-numbering">info = {    <span class="hljs-string">‘stu1101‘</span>: <span class="hljs-string">"台湾"</span>,    <span class="hljs-string">‘stu1102‘</span>: <span class="hljs-string">"钓鱼岛"</span>,    <span class="hljs-string">‘stu1103‘</span>: <span class="hljs-string">"南海"</span>,}</code><ul class="pre-numbering"><li>1</li><li>2</li><li>3</li><li>4</li><li>5</li></ul><div class="save_code tracking-ad" data-mod="popu_249"><a href="javascript:;" target="_blank"><img src="http://static.blog.csdn.net/images/save_snippets.png"></a></div><ul class="pre-numbering"><li>1</li><li>2</li><li>3</li><li>4</li><li>5</li></ul></pre><p>字典的特性:</p><ul><li>dict是无序的</li><li>key必须是唯一的,so 天生去重</li></ul><pre class="prettyprint" name="code"><code class="language-python hljs  has-numbering">增加或修改    info[<span class="hljs-string">"stu"</span>] = <span class="hljs-string">"fgf"</span>         <span class="hljs-comment"># 存在为修改,不存在为添加</span>删除    <span class="hljs-keyword">del</span> info[<span class="hljs-string">"stu"</span>]             <span class="hljs-comment"># 删除</span>    info.pop(<span class="hljs-string">"stu"</span>)查找    <span class="hljs-string">"fgf"</span> <span class="hljs-keyword">in</span> info               <span class="hljs-comment"># 标准用法</span>    info.get(<span class="hljs-string">"stu"</span>)             <span class="hljs-comment"># 获取</span>    info[<span class="hljs-string">"stu"</span>]                 <span class="hljs-comment"># 如果不存在,就报错,get不会,不存在返回None</span>-----------------------------------------------------------------------------取Values    info.values()取keys    info.keys()setdefault    info.setdefault(<span class="hljs-string">"stu1102"</span>, <span class="hljs-string">"小日本"</span>)  <span class="hljs-comment"># key有则不变,没有就创建</span>update    b = {<span class="hljs-number">1</span>:<span class="hljs-number">2</span>,<span class="hljs-number">3</span>:<span class="hljs-number">4</span>, <span class="hljs-string">"stu1102"</span>:<span class="hljs-string">"钓鱼岛是中国的"</span>}    info.update(b)              <span class="hljs-comment"># 类似列表的extend</span>info.items()</code><ul class="pre-numbering"><li>1</li><li>2</li><li>3</li><li>4</li><li>5</li><li>6</li><li>7</li><li>8</li><li>9</li><li>10</li><li>11</li><li>12</li><li>13</li><li>14</li><li>15</li><li>16</li><li>17</li><li>18</li><li>19</li><li>20</li></ul><div class="save_code tracking-ad" data-mod="popu_249"><a href="javascript:;" target="_blank"><img src="http://static.blog.csdn.net/images/save_snippets.png"></a></div><ul class="pre-numbering"><li>1</li><li>2</li><li>3</li><li>4</li><li>5</li><li>6</li><li>7</li><li>8</li><li>9</li><li>10</li><li>11</li><li>12</li><li>13</li><li>14</li><li>15</li><li>16</li><li>17</li><li>18</li><li>19</li><li>20</li></ul></pre><p>循环字典</p><pre class="prettyprint" name="code"><code class="hljs python has-numbering"><span class="hljs-comment"># 方法1</span><span class="hljs-keyword">for</span> index,item <span class="hljs-keyword">in</span> enumerate(info):    print(index,item)<span class="hljs-comment"># 方法2</span><span class="hljs-keyword">for</span> key <span class="hljs-keyword">in</span> info:  <span class="hljs-comment"># 效果一样,比下面高效</span>    print(key,info[key])<span class="hljs-comment"># 方法3</span><span class="hljs-keyword">for</span> k,v <span class="hljs-keyword">in</span> info.items(): <span class="hljs-comment">#会先把dict转成list,数据里大时莫用</span>    print(k,v)</code><ul class="pre-numbering"><li>1</li><li>2</li><li>3</li><li>4</li><li>5</li><li>6</li><li>7</li><li>8</li><li>9</li></ul><div class="save_code tracking-ad" data-mod="popu_249"><a href="javascript:;" target="_blank"><img src="http://static.blog.csdn.net/images/save_snippets.png"></a></div><ul class="pre-numbering"><li>1</li><li>2</li><li>3</li><li>4</li><li>5</li><li>6</li><li>7</li><li>8</li><li>9</li></ul></pre><h3 id="七深copy和浅copy"><a name="t7"></a><strong>七、深copy和浅copy</strong></h3><ol><li><p>数字和字符串 <br>上篇提了:对于数字数字和字符串一旦创建便不能被修改,假如对于字符串进行替代操作,只会在内存中重新生产一个字符串,而对于原字符串,并没有改变。</p></li><li><p>字典、列表等<a href="http://lib.csdn.net/base/datastructure" class="replace_word" title="算法与数据结构知识库" target="_blank" style="color:#df3434; font-weight:bold;">数据结构</a></p></li></ol><pre class="prettyprint" name="code"><code class="hljs go has-numbering">alphabet = [<span class="hljs-string">"A"</span>,<span class="hljs-string">"B"</span>,<span class="hljs-string">"C"</span>,[<span class="hljs-string">"L"</span>,<span class="hljs-string">"M"</span>,<span class="hljs-string">"N"</span>]]alphabet2 = alphabet.<span class="hljs-built_in">copy</span>()alphabet3 = alphabet<span class="hljs-keyword">import</span> <span class="hljs-built_in">copy</span>alphabet4 = <span class="hljs-built_in">copy</span>.<span class="hljs-built_in">copy</span>(alphabet)alphabet5 = <span class="hljs-built_in">copy</span>.deepcopy(alphabet)</code><ul class="pre-numbering"><li>1</li><li>2</li><li>3</li><li>4</li><li>5</li><li>6</li><li>7</li></ul><div class="save_code tracking-ad" data-mod="popu_249"><a href="javascript:;" target="_blank"><img src="http://static.blog.csdn.net/images/save_snippets.png"></a></div><ul class="pre-numbering"><li>1</li><li>2</li><li>3</li><li>4</li><li>5</li><li>6</li><li>7</li></ul></pre><p>请想一下:如果对alphabet的值做更改,其他四个变量的值会不会变化呢?</p><pre class="prettyprint" name="code"><code class="hljs markdown has-numbering">alphabet[2] = 2alphabet[<span class="hljs-link_label">3</span>][<span class="hljs-link_reference">1</span>] = 7&gt;&gt;&gt; alphabet[‘A‘, ‘B‘, 2, [‘L‘, 7, ‘N‘]]</code><ul class="pre-numbering"><li>1</li><li>2</li><li>3</li><li>4</li></ul><div class="save_code tracking-ad" data-mod="popu_249"><a href="javascript:;" target="_blank"><img src="http://static.blog.csdn.net/images/save_snippets.png"></a></div><ul class="pre-numbering"><li>1</li><li>2</li><li>3</li><li>4</li></ul></pre><p>下面分别看一下其他四个变量的值:</p><pre class="prettyprint" name="code"><code class="hljs python has-numbering"><span class="hljs-prompt">&gt;&gt;&gt; </span>alphabet    <span class="hljs-comment"># 更改后的值</span>[<span class="hljs-string">‘A‘</span>, <span class="hljs-string">‘B‘</span>, <span class="hljs-number">2</span>, [<span class="hljs-string">‘L‘</span>, <span class="hljs-number">7</span>, <span class="hljs-string">‘N‘</span>]]<span class="hljs-prompt">&gt;&gt;&gt; </span>alphabet2   <span class="hljs-comment"># list.copy()</span>[<span class="hljs-string">‘A‘</span>, <span class="hljs-string">‘B‘</span>, <span class="hljs-string">‘C‘</span>, [<span class="hljs-string">‘L‘</span>, <span class="hljs-number">7</span>, <span class="hljs-string">‘N‘</span>]]<span class="hljs-prompt">&gt;&gt;&gt; </span>alphabet3   <span class="hljs-comment"># "="赋值</span>[<span class="hljs-string">‘A‘</span>, <span class="hljs-string">‘B‘</span>, <span class="hljs-number">2</span>, [<span class="hljs-string">‘L‘</span>, <span class="hljs-number">7</span>, <span class="hljs-string">‘N‘</span>]]<span class="hljs-prompt">&gt;&gt;&gt; </span>alphabet4   <span class="hljs-comment"># copy.copy()</span>[<span class="hljs-string">‘A‘</span>, <span class="hljs-string">‘B‘</span>, <span class="hljs-string">‘C‘</span>[<span class="hljs-string">‘L‘</span>, <span class="hljs-number">7</span>, <span class="hljs-string">‘N‘</span>]]<span class="hljs-prompt">&gt;&gt;&gt; </span>alphabet5   <span class="hljs-comment"># copy.deepcopy()</span>[<span class="hljs-string">‘A‘</span>, <span class="hljs-string">‘B‘</span>, <span class="hljs-string">‘C‘</span>[<span class="hljs-string">‘L‘</span>, <span class="hljs-string">‘M‘</span>, <span class="hljs-string">‘N‘</span>]]</code><ul class="pre-numbering"><li>1</li><li>2</li><li>3</li><li>4</li><li>5</li><li>6</li><li>7</li><li>8</li><li>9</li><li>10</li></ul><div class="save_code tracking-ad" data-mod="popu_249"><a href="javascript:;" target="_blank"><img src="http://static.blog.csdn.net/images/save_snippets.png"></a></div><ul class="pre-numbering"><li>1</li><li>2</li><li>3</li><li>4</li><li>5</li><li>6</li><li>7</li><li>8</li><li>9</li><li>10</li></ul></pre><p><strong>总结一下</strong> <br>1、直接“=”赋值,都指向同一个内存地址,alphabet变,alphabet3也变。和简单的数字、字符串不一样 <br>2、list.copy()和copy模块的copy.copy()一样,都是浅copy,只copy了第一层,下面的层只是copy内存地址,源变量深层被更改,则更改。 <br>3、完全克隆,不只拷贝内存地址,则要深copy,使用copy模块的copy.deepcopy()</p><p>转载请务必保留此出处:<a href="http://blog.csdn.net/fgf00/article/details/52098926">http://blog.csdn.net/fgf00/article/details/52098926</a></p><p>字典的fromkeys用法也是一样。如下:</p><pre class="prettyprint" name="code"><code class="hljs python has-numbering"><span class="hljs-prompt">&gt;&gt;&gt; </span>deposit = dict.fromkeys([<span class="hljs-string">‘husband‘</span>,<span class="hljs-string">‘wife‘</span>],{<span class="hljs-string">"总存款:"</span>:<span class="hljs-string">"100w"</span>})<span class="hljs-prompt">&gt;&gt;&gt; </span>deposit{<span class="hljs-string">‘husband‘</span>: <span class="hljs-string">‘100w存款‘</span>, <span class="hljs-string">‘wife‘</span>: <span class="hljs-string">‘100w存款‘</span>}<span class="hljs-prompt">&gt;&gt;&gt; </span>deposit[<span class="hljs-string">‘husband‘</span>][<span class="hljs-string">"总存款:"</span>] = <span class="hljs-string">"80w"</span><span class="hljs-prompt">&gt;&gt;&gt; </span>deposit{<span class="hljs-string">‘husband‘</span>: {<span class="hljs-string">‘总存款:‘</span>: <span class="hljs-string">‘80w‘</span>}, <span class="hljs-string">‘wife‘</span>: {<span class="hljs-string">‘总存款:‘</span>: <span class="hljs-string">‘80w‘</span>}}<span class="hljs-comment"># 改其中一个的值,其他的值就都改了。第一层不变,深层就都变了,</span></code><ul class="pre-numbering"><li>1</li><li>2</li><li>3</li><li>4</li><li>5</li><li>6</li><li>7</li><li>8</li></ul><div class="save_code tracking-ad" data-mod="popu_249"><a href="javascript:;" target="_blank"><img src="http://static.blog.csdn.net/images/save_snippets.png"></a></div><ul class="pre-numbering"><li>1</li><li>2</li><li>3</li><li>4</li><li>5</li><li>6</li><li>7</li><li>8</li></ul></pre></div>        <script type="text/javascript">            $(function () {                $(pre.prettyprint code).each(function () {                    var lines = $(this).text().split(\n).length;                    var $numbering = $(<ul></ul>).addClass(pre-numbering).hide();                    $(this).addClass(has-numbering).parent().append($numbering);                    for (i = 1; i <= lines; i++) {                        $numbering.append($(<li></li>).text(i));                    };                    $numbering.fadeIn(1700);                });            });        </script>   </div><!-- Baidu Button BEGIN --><div class="bdsharebuttonbox tracking-ad bdshare-button-style0-16" style="float: right;" data-mod="popu_172" data-bd-bind="1487066653638"><a href="#" class="bds_more" data-cmd="more" style="background-position:0 0 !important; background-image: url(http://bdimg.share.baidu.com/static/api/img/share/icons_0_16.png?v=d754dcc0.png) !important" target="_blank"></a><a href="#" class="bds_qzone" data-cmd="qzone" title="分享到QQ空间" style="background-position:0 -52px !important" target="_blank"></a><a href="#" class="bds_tsina" data-cmd="tsina" title="分享到新浪微博" style="background-position:0 -104px !important" target="_blank"></a><a href="#" class="bds_tqq" data-cmd="tqq" title="分享到腾讯微博" style="background-position:0 -260px !important" target="_blank"></a><a href="#" class="bds_renren" data-cmd="renren" title="分享到人人网" style="background-position:0 -208px !important" target="_blank"></a><a href="#" class="bds_weixin" data-cmd="weixin" title="分享到微信" style="background-position:0 -1612px !important" target="_blank"></a></div><script>window._bd_share_config = { "common": { "bdSnsKey": {}, "bdText": "", "bdMini": "1", "bdMiniList": false, "bdPic": "", "bdStyle": "0", "bdSize": "16" }, "share": {} }; with (document) 0[(getElementsByTagName(head)[0] || body).appendChild(createElement(script)).src = http://bdimg.share.baidu.com/static/api/js/share.js?v=89860593.js?cdnversion= + ~(-new Date() / 36e5)];</script><!-- Baidu Button END -->   <link rel="stylesheet" href="http://static.blog.csdn.net/css/blog_detail.css">    <!--172.16.140.12--><!-- Baidu Button BEGIN --><script type="text/javascript" id="bdshare_js" data="type=tools&amp;uid=1536434" src="http://bdimg.share.baidu.com/static/js/bds_s_v2.js?cdnversion=413075"></script><script type="text/javascript">    document.getElementById("bdshell_js").src = "http://bdimg.share.baidu.com/static/js/shell_v2.js?cdnversion=" + Math.ceil(new Date()/3600000)</script><!-- Baidu Button END -->         <div id="digg" articleid="52098926">            <dl id="btnDigg" class="digg digg_disable" onclick="btndigga();">                                <dt></dt>                <dd>0</dd>            </dl>                                     <dl id="btnBury" class="digg digg_disable" onclick="btnburya();">                                <dt></dt>                <dd>0</dd>                           </dl>                    </div>     <div class="tracking-ad" data-mod="popu_222"><a href="javascript:void(0);" target="_blank">&nbsp;</a>   </div>    <div class="tracking-ad" data-mod="popu_223"> <a href="javascript:void(0);" target="_blank">&nbsp;</a></div>    <script type="text/javascript">                function btndigga() {                    $(".tracking-ad[data-mod=‘popu_222‘] a").click();                }                function btnburya() {                    $(".tracking-ad[data-mod=‘popu_223‘] a").click();                }            </script>   <ul class="article_next_prev">                <li class="prev_article"><span onclick="_gaq.push([‘_trackEvent‘,‘function‘, ‘onclick‘, ‘blog_articles_shangyipian‘]);location.href=http://www.mamicode.com/‘/fgf00/article/details/52061971‘;">上一篇</span><a href="/fgf00/article/details/52061971" onclick="_gaq.push([‘_trackEvent‘,‘function‘, ‘onclick‘, ‘blog_articles_shangyipian‘])">Python(一)介绍、安装、使用</a></li>                <li class="next_article"><span onclick="_gaq.push([‘_trackEvent‘,‘function‘, ‘onclick‘, ‘blog_articles_xiayipian‘]);location.href=http://www.mamicode.com/‘/fgf00/article/details/52167245‘;">下一篇</span><a href="/fgf00/article/details/52167245" onclick="_gaq.push([‘_trackEvent‘,‘function‘, ‘onclick‘, ‘blog_articles_xiayipian‘])">Python(三)集合、文件操作、字符编码和函数</a></li>    </ul>    <div style="clear:both; height:10px;"></div>        <div class="similar_article" style="">                <h4>我的同类文章</h4>                <div class="similar_c" style="margin:20px 0px 0px 0px">                    <div class="similar_c_t">                                <label class="similar_cur">                                    <span style="cursor:pointer" onclick="GetCategoryArticles(‘5985977‘,‘fgf00‘,‘foot‘,‘52098926‘);">Python开发<em>(24)</em></span>                                </label>                    </div>                                       <div class="similar_wrap tracking-ad" data-mod="popu_141" style="max-height:195px;">                        <a href="http://blog.csdn.net" style="display:none" target="_blank">http://blog.csdn.net</a>                        <ul class="similar_list fl"><li><em></em><a href="http://blog.csdn.net/fgf00/article/details/53522613" id="foot_aritcle_53522613undefined9660331199982566" target="_blank" title="Django 安装使用基础">Django 安装使用基础</a><span>2016-12-08</span><label><i>阅读</i><b>192</b></label></li> <li><em></em><a href="http://blog.csdn.net/fgf00/article/details/52976250" id="foot_aritcle_52976250undefined1500115655767782" target="_blank" title="python(十二)上:mysql安装使用详细教程">python(十二)上:mysql安装使用详细教程</a><span>2016-10-30</span><label><i>阅读</i><b>1121</b></label></li> <li><em></em><a href="http://blog.csdn.net/fgf00/article/details/52917154" id="foot_aritcle_52917154undefined4018463069851428" target="_blank" title="python(十一)下:Redis安装配置及使用详解">python(十一)下:Redis安装配置及使用详解</a><span>2016-10-24</span><label><i>阅读</i><b>484</b></label></li> <li><em></em><a href="http://blog.csdn.net/fgf00/article/details/52793739" id="foot_aritcle_52793739undefined35066250418077605" target="_blank" title="python(十)下:事件驱动与 阻塞IO、非阻塞IO、IO多路复用、异步IO">python(十)下:事件驱动与 阻塞IO、非阻塞IO、IO多路复用、异步IO</a><span>2016-10-12</span><label><i>阅读</i><b>2240</b></label></li> <li><em></em><a href="http://blog.csdn.net/fgf00/article/details/52773459" id="foot_aritcle_52773459undefined5750448822327963" target="_blank" title="python(九)线程与进程(上):线程">python(九)线程与进程(上):线程</a><span>2016-10-10</span><label><i>阅读</i><b>459</b></label></li> <li><em></em><a href="http://blog.csdn.net/fgf00/article/details/52556663" id="foot_aritcle_52556663undefined22206659899272352" target="_blank" title="python(七)下:初识socket网络编程">python(七)下:初识socket网络编程</a><span>2016-09-16</span><label><i>阅读</i><b>199</b></label></li> </ul>                        <ul class="similar_list fr"><li><em></em><a href="http://blog.csdn.net/fgf00/article/details/53512289" id="foot_aritcle_53512289undefined7784439466895436" target="_blank" title="web框架本质">web框架本质</a><span>2016-12-08</span><label><i>阅读</i><b>116</b></label></li> <li><em></em><a href="http://blog.csdn.net/fgf00/article/details/52949973" id="foot_aritcle_52949973undefined38233673925439726" target="_blank" title="python(十二)下:ORM框架SQLAlchemy使用学习">python(十二)下:ORM框架SQLAlchemy使用学习</a><span>2016-10-27</span><label><i>阅读</i><b>624</b></label></li> <li><em></em><a href="http://blog.csdn.net/fgf00/article/details/52872730" id="foot_aritcle_52872730undefined9738900768555943" target="_blank" title="python(十一)上:RabbitMQ 使用详细介绍">python(十一)上:RabbitMQ 使用详细介绍</a><span>2016-10-20</span><label><i>阅读</i><b>911</b></label></li> <li><em></em><a href="http://blog.csdn.net/fgf00/article/details/52790360" id="foot_aritcle_52790360undefined3340990519263538" target="_blank" title="python(十)线程与进程(中):进程、协程">python(十)线程与进程(中):进程、协程</a><span>2016-10-11</span><label><i>阅读</i><b>396</b></label></li> <li><em></em><a href="http://blog.csdn.net/fgf00/article/details/52752746" id="foot_aritcle_52752746undefined4286822328944917" target="_blank" title="python(八)socket网络编程">python(八)socket网络编程</a><span>2016-10-07</span><label><i>阅读</i><b>428</b></label></li> </ul>                    <a href="http://blog.csdn.net/fgf00/article/category/5985977" class="MoreArticle">更多文章</a></div>                </div>            </div>        <script type="text/javascript">        $(function () {            GetCategoryArticles(5985977, fgf00,foot,52098926);        });    </script>      </div>

 

234234