<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
  <channel>
    <title>RSS - Jamin Zhang</title>
    <description>Jamin Zhang - To be empty in order to be full!</description>
    <link>http://jaminzhang.me</link>
    <atom:link href="http://jaminzhang.me//rss/" rel="self" type="application/rss+xml" />
    <pubDate>Tue, 17 Sep 2019 20:58:39 +0800</pubDate>
    <lastBuildDate>Tue, 17 Sep 2019 20:58:39 +0800</lastBuildDate>
    <generator>Jamin Zhang</generator>
    
      <item>
        <title>苹果计划在 Mac 上使用自产芯片取代英特尔处理器</title>
        <description>&lt;h1 id=&quot;引言&quot;&gt;引言&lt;/h1&gt;

&lt;p&gt;前几天，出了一个重大新闻，&lt;a href=&quot;https://wallstreetcn.com/articles/3269701&quot;&gt;媒体称苹果计划摆脱英特尔 使用自产 Mac 芯片 英特尔股价大跌&lt;/a&gt;，
苹果确实很牛，几乎所有东西（硬件、软件）都想要自产，
去年我写了篇博文 &lt;a href=&quot;http://jaminzhang.github.io/mac/The-Reason-Of-MacBook-Pro-2017-Dont-Support-32GB-RAM/&quot;&gt;MacBook Pro 2017 不支持 32GB 内存的原因&lt;/a&gt;，
里面就说到了 Intel Core 系列 CPU 不支持 LPDDR4 内存，所以苹果 MacBook Pro 最高只能支持 16GB 内存，
这里还要提下，前几天 Intel 发布了全新的第八代酷睿移动处理器 Core i9，来自 AppleInsider 的消息显示，
苹果将会在新款 15 英寸的 MacBook Pro 产品上使用上 Intel 最新的 Core i9 处理器，但其仍然不支持 LPDDR4 内存，
我想苹果肯定是想上 LPDDR4 内存的，
但无奈 Intel 拖了后腿，苹果感到了受制于 Intel（当然还有更多原因，这里只指出内存方面），所以才会想要自产 Mac 处理器。&lt;/p&gt;

&lt;p&gt;虽然苹果计划今后放弃使用 Intel 处理器，但是“好汉不吃眼前亏”，眼下 Intel 的芯片性能还是比苹果强不少，
直接实行这个计划还是不太现实，而按照他们的计划来说，要在 2020 年的时候才有新的进展。&lt;/p&gt;

&lt;h1 id=&quot;对我的购机影响&quot;&gt;对我的购机影响&lt;/h1&gt;

&lt;p&gt;我的换机标准一直没变，作为 Pro 用户，我现在的第一需求是要支持 32GB 内存，看来还是要至少等到明年 2019 年再看？
我计划在近 1-2 年内换机。&lt;/p&gt;

&lt;h1 id=&quot;ref&quot;&gt;Ref&lt;/h1&gt;
&lt;p&gt;&lt;a href=&quot;https://www.macrumors.com/2018/04/02/apple-custom-mac-chips-2020/&quot;&gt;Apple Plans to Ditch Intel and Use Custom Mac Chips Starting in 2020&lt;/a&gt;&lt;br /&gt;
&lt;a href=&quot;https://www.zhihu.com/question/270874395&quot;&gt;如何评价苹果计划在 Mac 上使用自产芯片取代英特尔处理器?&lt;/a&gt;&lt;br /&gt;
&lt;a href=&quot;https://www.macrumors.com/2018/04/03/intel-debuts-core-i9-coffee-lake-eighth-gen/&quot;&gt;Intel’s New Core i9 and Coffee Lake Chips Pave Way for Quad-Core 13” MacBook Pro, Mac Mini Refresh, and More&lt;/a&gt;&lt;br /&gt;
&lt;a href=&quot;http://tech.sina.com.cn/n/k/2018-04-04/doc-ifysuuya3112999.shtml&quot;&gt;苹果新 MacBook Pro 曝光：搭载 Intel 最新 6 核 i9 处理器&lt;/a&gt;&lt;br /&gt;
&lt;a href=&quot;https://ark.intel.com/products/134903/Intel-Core-i9-8950HK-Processor-12M-Cache-up-to-4_60-GHz&quot;&gt;Intel® Core™ i9-8950HK Processor&lt;/a&gt;&lt;br /&gt;
&lt;a href=&quot;https://www.cnbeta.com/articles/tech/714081.htm&quot;&gt;苹果弃用英特尔：想说分手不容易&lt;/a&gt;&lt;/p&gt;
</description>
        <pubDate>Sat, 07 Apr 2018 00:00:00 +0800</pubDate>
        <link>http://jaminzhang.me/mac/Apple-Custom-Mac-Chips-in-2020/</link>
        <guid isPermaLink="true">http://jaminzhang.me/mac/Apple-Custom-Mac-Chips-in-2020/</guid>
        
        <category>Mac</category>
        
      </item>
    
      <item>
        <title>学习比特币</title>
        <description>&lt;h1 id=&quot;引言&quot;&gt;引言&lt;/h1&gt;
&lt;p&gt;新的一年到了，由于某些原因使我踏入到投资数字货币的圈子，在看到交易所上眼花缭乱的各种数字货币时，
我迷茫了，这些币到底是什么？继而引发了我对数字货币兴趣，想要理解它们，
我的思路是首先全面了解学习比特币（比特币是第一个数字货币），
以此为基准，然后再去理解其他数字货币。&lt;/p&gt;

&lt;h1 id=&quot;比特币相关书籍&quot;&gt;比特币相关书籍&lt;/h1&gt;

&lt;p&gt;&lt;a href=&quot;http://book.8btc.com/books/6/masterbitcoin2cn/_book/&quot;&gt;《精通比特币（第二版）》&lt;/a&gt;&lt;br /&gt;
&lt;a href=&quot;https://github.com/tianmingyun/MasterBitcoin2CN&quot;&gt;《精通比特币》第二版 区块链研究社 云天明联合出品&lt;/a&gt;&lt;br /&gt;
&lt;a href=&quot;https://github.com/bitcoinbook/bitcoinbook&quot;&gt;Mastering Bitcoin 2nd Edition - Programming the Open Blockchain https://bitcoinbook.info/&lt;/a&gt;&lt;/p&gt;
</description>
        <pubDate>Mon, 01 Jan 2018 00:00:00 +0800</pubDate>
        <link>http://jaminzhang.me/bitcoin/Learning-Bitcoin/</link>
        <guid isPermaLink="true">http://jaminzhang.me/bitcoin/Learning-Bitcoin/</guid>
        
        <category>Bitcoin</category>
        
      </item>
    
      <item>
        <title>MacBook Pro 2017 不支持 32GB 内存的原因</title>
        <description>&lt;h1 id=&quot;引言&quot;&gt;引言&lt;/h1&gt;
&lt;p&gt;我现在的笔记本电脑已经用了好几年的时间了，需要更新换代了。&lt;br /&gt;
首选是最新款 MacBook Pro 15”，但有一个原因阻碍了马上购买，就是它不支持 32GB 内存。
自认为 Pro 用户的我，还是想等待 32GB 内存版本。&lt;br /&gt;
那为什么它不支持 32GB 内存呢？网上有很多文章分析了，深入分析可以得出好些原因，我附在 Ref 中。&lt;br /&gt;
我把最可能的本质原因简要总结一下，如下。&lt;/p&gt;

&lt;h1 id=&quot;原因&quot;&gt;原因&lt;/h1&gt;

&lt;h2 id=&quot;1用于笔记本电脑的-lpddr3-单颗容量现在最大只有-32gb4gb&quot;&gt;1.用于笔记本电脑的 LPDDR3 单颗容量现在最大只有 32Gb(4GB)&lt;/h2&gt;
&lt;h2 id=&quot;2-intel-core-系列-cpu-现在还不支持-lpddr4-内存&quot;&gt;2. Intel Core 系列 CPU 现在还不支持 LPDDR4 内存&lt;/h2&gt;

&lt;p&gt;MacBook Pro 2017 上配置板载内存是 4 颗 32Gb(4GB) 的 LPDDR3 内存芯片，
现在 LPDDR3 单颗容量最大为 48Gb(8GB)，三星家出的，但它是用于智能手机的，不能用于笔记本电脑，&lt;br /&gt;
现在能用于笔记本电脑的 LPDDR3 单颗容量最大只有 32Gb(4GB)，4 颗上限就是 16GB。
要实现 32GB，只能采用 8 颗粒的方案，可以在背面多放 4 颗 DRAM，这需要更改现有的 PCB 布局，但苹果并没有这么做。
另外，如果使用 LPDDR4 内存呢，现在能量产的 LPDDR4 内存可以达到单颗粒 64Gb(封装方式支持问题暂不考虑)，
但 Intel Kaby Lake CPU 并不支持 LPDDR4 内存。&lt;/p&gt;

&lt;h2 id=&quot;个人期望&quot;&gt;个人期望&lt;/h2&gt;

&lt;p&gt;苹果现在把 MacBook Pro 重点放在轻薄上，更改笔记本内部布局，增加更多 DRAM 的可能性并不大。&lt;br /&gt;
用于笔记本电脑的 LPDDR3 单颗容量现在最大只有 32Gb(4GB)，增加到 64Gb 的可能性也不大。&lt;br /&gt;
所以现在大概只能期望更换 LPDDR4 内存才能达到 32GB 内存目标，进一步，这个只能期望 Intel 的 CPU 能够支持 LPDDR4 内存。&lt;br /&gt;
关于 Intel CPU 什么时候能支持 LPDDR4 内存又是一个不可预期的问题（估计从下一个 10nm Cannon Lake 系列开始，Intel 给出的时间是在 2017 年底）。&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;总结：&lt;/strong&gt; MacBook Pro 什么时候能支持 32GB 内存很大程度上依赖 Intel CPU 什么时候能支持 LPDDR4 内存。&lt;br /&gt;
所以这段时间也一直在关注 Intel CPU 的一些新闻。&lt;/p&gt;

&lt;h1 id=&quot;ref&quot;&gt;Ref&lt;/h1&gt;
&lt;p&gt;&lt;a href=&quot;https://www.zhihu.com/question/60794758&quot;&gt;如何看待苹果 2017 款 MacBook Pro 仍然使用 LPDDR3 内存？&lt;/a&gt;&lt;br /&gt;
&lt;a href=&quot;http://www.samsung.com/semiconductor/products/dram/mobile-dram/&quot;&gt;Samsung Mobile DRAM&lt;/a&gt;&lt;br /&gt;
&lt;a href=&quot;https://www.skhynix.com/products.do?ct1=36&amp;amp;ct2=41&amp;amp;lang=eng&quot;&gt;Hynix DRAM&lt;/a&gt;&lt;br /&gt;
&lt;a href=&quot;https://www.micron.com/products/dram&quot;&gt;Micron DRAM&lt;/a&gt;&lt;/p&gt;
</description>
        <pubDate>Mon, 25 Sep 2017 00:00:00 +0800</pubDate>
        <link>http://jaminzhang.me/mac/The-Reason-Of-MacBook-Pro-2017-Dont-Support-32GB-RAM/</link>
        <guid isPermaLink="true">http://jaminzhang.me/mac/The-Reason-Of-MacBook-Pro-2017-Dont-Support-32GB-RAM/</guid>
        
        <category>Mac</category>
        
      </item>
    
      <item>
        <title>CentOS 下安装 Python 3.X/PIP/Git 2.X</title>
        <description>&lt;h1 id=&quot;安装依赖&quot;&gt;安装依赖&lt;/h1&gt;

&lt;p&gt;&lt;code class=&quot;highlighter-rouge&quot;&gt;yum install -y gcc openssl openssl-devel sqlite-devel xml2 libxml2-devel libxslt libxslt-devel python-pyasn1 libffi-devel python-pyasn1-modules &lt;/code&gt;&lt;/p&gt;

&lt;h1 id=&quot;安装-python-3x-和-pip-python-3-自带-pip&quot;&gt;安装 Python 3.X 和 PIP (Python 3 自带 PIP)&lt;/h1&gt;

&lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;
wget https://www.python.org/ftp/python/3.5.3/Python-3.5.3.tgz
&lt;span class=&quot;nb&quot;&gt;tar &lt;/span&gt;xzvf Python-3.5.3.tgz
&lt;span class=&quot;nb&quot;&gt;cd &lt;/span&gt;Python-3.5.3
./configure 
make
make install

python3
pip3 &lt;span class=&quot;nt&quot;&gt;--version&lt;/span&gt;

&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h1 id=&quot;安装-git-2x&quot;&gt;安装 Git 2.X&lt;/h1&gt;

&lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;
&lt;span class=&quot;c&quot;&gt;## 安装依赖(依据实际需求，这里我要使用)&lt;/span&gt;
yum install libcurl-devel &lt;span class=&quot;nt&quot;&gt;-y&lt;/span&gt;
yum install expat-devel perl-ExtUtils-MakeMaker &lt;span class=&quot;nt&quot;&gt;-y&lt;/span&gt;

wget https://www.kernel.org/pub/software/scm/git/git-2.9.5.tar.gz
&lt;span class=&quot;nb&quot;&gt;tar &lt;/span&gt;xzvf git-2.9.5.tar.gz
&lt;span class=&quot;nb&quot;&gt;cd &lt;/span&gt;git-2.9.5
./configure 
make
make install

mv /usr/bin/git /usr/bin/git-1.7    &lt;span class=&quot;c&quot;&gt;# 备份旧版本 Git &lt;/span&gt;
git &lt;span class=&quot;nt&quot;&gt;--version&lt;/span&gt;   &lt;span class=&quot;c&quot;&gt;# Git 默认编译安装在 /usr/local/bin/&lt;/span&gt;

&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h1 id=&quot;ref&quot;&gt;Ref&lt;/h1&gt;
&lt;p&gt;&lt;a href=&quot;https://python.freelycode.com/contribution/detail/284&quot;&gt;Redhat/Centos/Fedora 下 Python, Pip 和 Git 的安装&lt;/a&gt;&lt;/p&gt;
</description>
        <pubDate>Fri, 01 Sep 2017 00:00:00 +0800</pubDate>
        <link>http://jaminzhang.me/python/Install-Python-3-PIP-Git-2-in-CentOS/</link>
        <guid isPermaLink="true">http://jaminzhang.me/python/Install-Python-3-PIP-Git-2-in-CentOS/</guid>
        
        <category>Python</category>
        
      </item>
    
      <item>
        <title>4K 相关概念了解</title>
        <description>&lt;p&gt;4K 相关概念了解&lt;/p&gt;

&lt;h1 id=&quot;引言&quot;&gt;引言&lt;/h1&gt;

&lt;p&gt;2008 年左右，我对数字高清视频感兴趣，记得当时厂家在大力宣传 FullHD 全高清显示设备，&lt;br /&gt;
当时我也是购入了一台 FullHD 1920x1080 分辨率的显示器，当时 1080p 的内容还并不是那么多，全高清设备也并没有普及。&lt;br /&gt;
高清视频标准发展到现在，出现了 4K 标准，和当年的 FullHD 的情况很类似，标准已出，厂家大力宣传 4K 相关的显示设备。
这几年听得最多的就是 4K 电视了。我所了解到的 4K 内容渠道：4K BD, Youtube/Netflix 4K Streaming,
4K 电视频道（有线或卫星方式）。但是现在上面这些渠道上的 4K 内容还并不多。
由于我也有几年没有仔细了解 4K 概念，只是经常听到 4K 这个名词，花了点时间了解了下 4K 概念，参考 Wikipedia。&lt;/p&gt;

&lt;h1 id=&quot;ref&quot;&gt;Ref&lt;/h1&gt;
&lt;p&gt;&lt;a href=&quot;https://en.wikipedia.org/wiki/4K_resolution&quot;&gt;4K_resolution&lt;/a&gt;&lt;br /&gt;
&lt;a href=&quot;https://www.zhaiiker.com/titles/491.html&quot;&gt;4K 元年正式到来，这可能是最详尽的 4K 攻略&lt;/a&gt;&lt;br /&gt;
&lt;a href=&quot;https://www.zhaiiker.com/collection/beginnerofav&quot;&gt;影音入门专栏&lt;/a&gt;&lt;/p&gt;
</description>
        <pubDate>Sat, 01 Jul 2017 00:00:00 +0800</pubDate>
        <link>http://jaminzhang.me/video/Understand-4K-Related-Concept/</link>
        <guid isPermaLink="true">http://jaminzhang.me/video/Understand-4K-Related-Concept/</guid>
        
        <category>Video</category>
        
      </item>
    
      <item>
        <title>Python 基础 11-Python 技术领域</title>
        <description>&lt;h1 id=&quot;python-技术领域&quot;&gt;Python 技术领域&lt;/h1&gt;

&lt;ul&gt;
  &lt;li&gt;网站 Web 开发&lt;/li&gt;
  &lt;li&gt;App 后端开发&lt;/li&gt;
  &lt;li&gt;DevOps 运维开发：运维专业知识、一些第三方工具的使用&lt;/li&gt;
  &lt;li&gt;爬虫开发：beautiful soap/Scrapy&lt;/li&gt;
  &lt;li&gt;黑客技术: 计算机基础原理、黑客工具使用&lt;/li&gt;
  &lt;li&gt;数据科学：取数据、展示数据&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;img src=&quot;http://jaminzhang.github.io/images/Python/Python-Technology-Field.png&quot; alt=&quot;Python-Technology-Field&quot; /&gt;&lt;/p&gt;
</description>
        <pubDate>Sun, 11 Jun 2017 00:00:00 +0800</pubDate>
        <link>http://jaminzhang.me/python/Python-Fundamental-11-Python-Technology-Field/</link>
        <guid isPermaLink="true">http://jaminzhang.me/python/Python-Fundamental-11-Python-Technology-Field/</guid>
        
        <category>Python</category>
        
      </item>
    
      <item>
        <title>Python 基础 10-异常处理</title>
        <description>&lt;h1 id=&quot;异常处理&quot;&gt;异常处理&lt;/h1&gt;

&lt;ol&gt;
  &lt;li&gt;编写错误的代码会导致异常&lt;/li&gt;
  &lt;li&gt;为了让我们了解发生了什么，Python 会抛出一个异常对象。&lt;/li&gt;
  &lt;li&gt;异常对象也有类型，它的类型也有父类型，最终继承于基类 Exception。&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;img src=&quot;http://jaminzhang.github.io/images/Python/Python-Exception-Class.png&quot; alt=&quot;Python-Exception-Class&quot; /&gt;&lt;/p&gt;

&lt;h1 id=&quot;try-except-else-语句&quot;&gt;try except else 语句&lt;/h1&gt;

&lt;div class=&quot;language-python highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;
&lt;span class=&quot;k&quot;&gt;try&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;
    &lt;span class=&quot;err&quot;&gt;一段可能出错的代码&lt;/span&gt;             &lt;span class=&quot;c&quot;&gt;# 一般容易出错的场景：网络请求、读写写入、处理与外部系统的交互&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;except&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;ValueError&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;as&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;e&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;           &lt;span class=&quot;c&quot;&gt;# 把 ValueError 类型的异常对象赋值给变量 e&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;print&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;e&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;                      &lt;span class=&quot;c&quot;&gt;# 处理这个异常，当使用 print 打印 e 这个异常对象时，e 这个变量变成字符串，包含描述信息&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;except&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;Exception&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;
    &lt;span class=&quot;err&quot;&gt;处理其余所有的异常&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;else&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;
    &lt;span class=&quot;err&quot;&gt;没有异常时的处理代码&lt;/span&gt;

&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;except 捕获异常的语句可以有任意多个，同 else 语句一起是互斥的。&lt;/p&gt;

&lt;h1 id=&quot;try-finally-语句&quot;&gt;try finally 语句&lt;/h1&gt;

&lt;div class=&quot;language-python highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;
&lt;span class=&quot;k&quot;&gt;try&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;
    &lt;span class=&quot;err&quot;&gt;一段可能出错的代码&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;finally&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;
    &lt;span class=&quot;err&quot;&gt;最后一定会执行的代码，&lt;/span&gt;         &lt;span class=&quot;c&quot;&gt;# 无论前面代码是否出错，最后一定会执行的代码，&lt;/span&gt;
    &lt;span class=&quot;err&quot;&gt;例如&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;f&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;close&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt;                &lt;span class=&quot;c&quot;&gt;# 常用场景是关闭网络、关闭文件等&lt;/span&gt;
    

&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h1 id=&quot;抛出异常-rasie-语句&quot;&gt;抛出异常 rasie 语句&lt;/h1&gt;

&lt;p&gt;&lt;code class=&quot;highlighter-rouge&quot;&gt;rasie e&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;捕获到异常时，如果不想处理，想让更外层代码知道（因为代码是通过函数一层层调用的），
可以使用 rasie 语句来抛出异常到外层。&lt;/p&gt;

&lt;div class=&quot;language-python highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;
&lt;span class=&quot;k&quot;&gt;try&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;
    &lt;span class=&quot;nb&quot;&gt;int&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;a&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;except&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;ValueError&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;as&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;e&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;print&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;e&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;raise&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;e&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;

&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
</description>
        <pubDate>Sat, 10 Jun 2017 00:00:00 +0800</pubDate>
        <link>http://jaminzhang.me/python/Python-Fundamental-10-Exception-Process/</link>
        <guid isPermaLink="true">http://jaminzhang.me/python/Python-Fundamental-10-Exception-Process/</guid>
        
        <category>Python</category>
        
      </item>
    
      <item>
        <title>Python 基础 09-文件处理</title>
        <description>&lt;h1 id=&quot;写入文件&quot;&gt;写入文件&lt;/h1&gt;

&lt;div class=&quot;language-python highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;
&lt;span class=&quot;n&quot;&gt;poem&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;'''&lt;/span&gt;&lt;span class=&quot;se&quot;&gt;\
&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;Programming is fun,
When the work is done.
If you wanna make your work also fun:
    Use Python!
'''&lt;/span&gt;

&lt;span class=&quot;n&quot;&gt;f&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;open&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;'poem.txt'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;'w'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;           &lt;span class=&quot;c&quot;&gt;# 打开文件的方式：r/w/a，open 方法返回值是一个文件描述符，赋值给 f&lt;/span&gt;
                                    &lt;span class=&quot;c&quot;&gt;# 文件描述符可以理解成一个表示文件的对象&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;f&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;write&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;poem&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;                       &lt;span class=&quot;c&quot;&gt;# write text to file&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;f&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;close&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt;                           &lt;span class=&quot;c&quot;&gt;# close the file，打开文件后一定要关闭，如果不关闭，会占用系统的文件描述符资源&lt;/span&gt;

&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h1 id=&quot;读取文件&quot;&gt;读取文件&lt;/h1&gt;

&lt;div class=&quot;language-python highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;
&lt;span class=&quot;n&quot;&gt;f&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;open&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;'poem.txt'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;                &lt;span class=&quot;c&quot;&gt;# 默认为 r 模式&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;while&lt;/span&gt; &lt;span class=&quot;bp&quot;&gt;True&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;line&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;f&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;readline&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;len&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;line&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;==&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;              &lt;span class=&quot;c&quot;&gt;# 空行表示读取结束&lt;/span&gt;
        &lt;span class=&quot;k&quot;&gt;break&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;print&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;line&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;end&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;           &lt;span class=&quot;c&quot;&gt;# print 内容后面默认会增加一个 \n，这里 end 禁止结尾增加 \n，改为增加 &quot;&quot;&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;f&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;close&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt;                           &lt;span class=&quot;c&quot;&gt;# close the file&lt;/span&gt;

&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h1 id=&quot;使用-with-语句后-python-自动关闭文件&quot;&gt;使用 with 语句后 Python 自动关闭文件&lt;/h1&gt;

&lt;p&gt;使用 with 语句后，不用使用 close 方法关闭文件了。&lt;/p&gt;

&lt;div class=&quot;language-python highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;
&lt;span class=&quot;n&quot;&gt;poem&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;'''&lt;/span&gt;&lt;span class=&quot;se&quot;&gt;\
&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;Programming is fun,
When the work is done.
If you wanna make your work also fun:
    Use Python!
'''&lt;/span&gt;

&lt;span class=&quot;c&quot;&gt;# 写入文件&lt;/span&gt;

&lt;span class=&quot;k&quot;&gt;with&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;open&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;'poem.txt'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;'w'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;as&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;f&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;f&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;write&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;poem&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
    
    
&lt;span class=&quot;c&quot;&gt;# 读取文件&lt;/span&gt;

&lt;span class=&quot;k&quot;&gt;with&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;open&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;'poem.txt'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;as&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;f&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;while&lt;/span&gt; &lt;span class=&quot;bp&quot;&gt;True&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;
        &lt;span class=&quot;n&quot;&gt;line&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;f&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;readline&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt;
        &lt;span class=&quot;k&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;len&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;line&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;==&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;      
            &lt;span class=&quot;k&quot;&gt;break&lt;/span&gt;
        &lt;span class=&quot;k&quot;&gt;print&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;line&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;end&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;

&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

</description>
        <pubDate>Fri, 09 Jun 2017 00:00:00 +0800</pubDate>
        <link>http://jaminzhang.me/python/Python-Fundamental-08-File-Process/</link>
        <guid isPermaLink="true">http://jaminzhang.me/python/Python-Fundamental-08-File-Process/</guid>
        
        <category>Python</category>
        
      </item>
    
      <item>
        <title>Python 基础 08-类和对象</title>
        <description>&lt;h1 id=&quot;类和对象实例&quot;&gt;类和对象(实例)&lt;/h1&gt;

&lt;p&gt;之前我们学习了函数和模块等组织代码的方式，但随着代码的增多，函数和模块还是不够用。&lt;br /&gt;
根据有项研究，如果代码超过 10000 行，如果只用函数和模块来组织代码，那么程序员将很难掌控代码。
所以在大型项目中，为了更好地组织代码，会使用类和对象。&lt;/p&gt;

&lt;p&gt;类和对象之间的关系非常相似于概念和实体的关系。&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;http://jaminzhang.github.io/images/Python/Python-Class-Object.png&quot; alt=&quot;Python-Class-Object&quot; /&gt;&lt;/p&gt;

&lt;h1 id=&quot;创建类&quot;&gt;创建类&lt;/h1&gt;

&lt;div class=&quot;language-python highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;
&lt;span class=&quot;k&quot;&gt;class&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;Cat&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;object&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;):&lt;/span&gt;                      &lt;span class=&quot;c&quot;&gt;# 定义概念 猫：       PS: 注意使用 class 关键词，Python 3 中不需要&quot;(object)&quot;&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;leg_cnt&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;4&lt;/span&gt;                         &lt;span class=&quot;c&quot;&gt;# 腿数 = 4        PS: 可以做为类属性&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;__init__&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;bp&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;cat_name&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;):&lt;/span&gt;       &lt;span class=&quot;c&quot;&gt;# 定义 创建过程（实体，猫名）：   PS: 实例的创建过程，类的实例化，第一个参数 self 是必须的，  &lt;/span&gt;
                                        &lt;span class=&quot;c&quot;&gt;# self 可以理解为类实例化时的已经存在的初始实体对象，很多属性还没有被设置&lt;/span&gt;
        &lt;span class=&quot;bp&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;name&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;cat_name&lt;/span&gt;            &lt;span class=&quot;c&quot;&gt;# 实体.名字 = 猫名  PS: 给实体设置 name 属性，同时将传入的参数 cat_name 赋值给它&lt;/span&gt;
                                        &lt;span class=&quot;c&quot;&gt;# name 这个变量是附属于 self 实例的（self.name），不能够直接使用 name 变量&lt;/span&gt;
    
    &lt;span class=&quot;k&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;change_name&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;bp&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;cat_name&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;):&lt;/span&gt;    &lt;span class=&quot;c&quot;&gt;# 定义 改名字（实体，猫名）:  PS: 类里面的函数就叫类的方法，第一个参数是 self，类的方法实际上定义类这个概念能做什么&lt;/span&gt;
        &lt;span class=&quot;bp&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;name&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;cat_name&lt;/span&gt;            &lt;span class=&quot;c&quot;&gt;# 实体.名字 = 猫名&lt;/span&gt;
    
    &lt;span class=&quot;k&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;climb&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;bp&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;):&lt;/span&gt;                    &lt;span class=&quot;c&quot;&gt;# 定义 爬树(实体):&lt;/span&gt;
        &lt;span class=&quot;k&quot;&gt;print&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;cat &lt;/span&gt;&lt;span class=&quot;si&quot;&gt;%&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;s climb a tree&quot;&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;%&lt;/span&gt;   &lt;span class=&quot;c&quot;&gt;# 输出 （猫爬了树）&lt;/span&gt;
        &lt;span class=&quot;bp&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;name&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;

&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h1 id=&quot;创建并使用实例&quot;&gt;创建并使用实例&lt;/h1&gt;

&lt;div class=&quot;language-python highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;
&lt;span class=&quot;n&quot;&gt;tom&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;Cat&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;Tom&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;                &lt;span class=&quot;c&quot;&gt;# 类的实例化，Cat 实例化后赋值给 tom 这个变量，tom 是一只真正的猫，它的名字叫&quot;Tom&quot;&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;tom&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;chang_name&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;ATom&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;          &lt;span class=&quot;c&quot;&gt;# tom 改名字为 &quot;ATom&quot;&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;tom&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;climb&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt;                     &lt;span class=&quot;c&quot;&gt;# tom 去爬树&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;tom&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;leg_cnt&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;==&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;4&lt;/span&gt;                &lt;span class=&quot;c&quot;&gt;# True tom 的腿数是 4&lt;/span&gt;

&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h1 id=&quot;类的继承&quot;&gt;类的继承&lt;/h1&gt;

&lt;p&gt;继承的类叫做子类。&lt;/p&gt;

&lt;div class=&quot;language-python highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;
&lt;span class=&quot;k&quot;&gt;class&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;PersianCat&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Cat&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;):&lt;/span&gt;              &lt;span class=&quot;c&quot;&gt;# 定义概念 波斯猫（继承猫）：&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;__init&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;bp&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;cat_name&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;):&lt;/span&gt;     &lt;span class=&quot;c&quot;&gt;# 定义 创建过程（实体，猫名）：&lt;/span&gt;
        &lt;span class=&quot;nb&quot;&gt;super&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;PersianCat&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;bp&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;__init__&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;cat_name&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;  &lt;span class=&quot;c&quot;&gt;# 执行猫的创建过程（猫名），Python 3 中&quot;PersianCat, self&quot;可不写&lt;/span&gt;
    
    &lt;span class=&quot;k&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;jump&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;bp&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;):&lt;/span&gt;                 &lt;span class=&quot;c&quot;&gt;# 定义 跳(实体)：&lt;/span&gt;
        &lt;span class=&quot;k&quot;&gt;print&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;try jump&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;           &lt;span class=&quot;c&quot;&gt;# 打印 (&quot;try jump&quot;)&lt;/span&gt;

&lt;span class=&quot;n&quot;&gt;jack&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;PersianCat&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;jack&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;           &lt;span class=&quot;c&quot;&gt;# jack 是一只真实的波斯猫&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;jack&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;jump&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt;                         &lt;span class=&quot;c&quot;&gt;# jack 跳    &lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;jack&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;climb&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt;                        &lt;span class=&quot;c&quot;&gt;# jack 爬树&lt;/span&gt;
        
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h1 id=&quot;ref&quot;&gt;Ref&lt;/h1&gt;
&lt;p&gt;&lt;a href=&quot;http://www.runoob.com/python/python-object.html&quot;&gt;Python 面向对象&lt;/a&gt;&lt;br /&gt;
&lt;a href=&quot;http://blog.csdn.net/wklken/article/details/6313265&quot;&gt;Python 笔记——类定义&lt;/a&gt;&lt;/p&gt;
</description>
        <pubDate>Thu, 08 Jun 2017 00:00:00 +0800</pubDate>
        <link>http://jaminzhang.me/python/Python-Fundamental-08-Class-And-Object/</link>
        <guid isPermaLink="true">http://jaminzhang.me/python/Python-Fundamental-08-Class-And-Object/</guid>
        
        <category>Python</category>
        
      </item>
    
      <item>
        <title>Python 基础 07-高级数据类型</title>
        <description>&lt;h1 id=&quot;元组&quot;&gt;元组&lt;/h1&gt;

&lt;ol&gt;
  &lt;li&gt;与列表很相似，定义为 (1, “123”, 56)&lt;/li&gt;
  &lt;li&gt;不同的是，元组是不能改变的，类似于常量，元组是不能增加或删除元素的&lt;/li&gt;
  &lt;li&gt;(2) 其实 2，”()” 理解成数学上的括号，(2,) 是元组，里面只有一个元素&lt;/li&gt;
&lt;/ol&gt;

&lt;h1 id=&quot;字典&quot;&gt;字典&lt;/h1&gt;

&lt;p&gt;字典表示的是一种映射关系。
以下就是一个字典。&lt;/p&gt;

&lt;div class=&quot;language-python highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;
&lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;s&quot;&gt;&quot;123&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;123&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;
	&lt;span class=&quot;mi&quot;&gt;456&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;hello&quot;&lt;/span&gt;

&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;

&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;冒号左边称为键（Key），它是一个常量，右边称为值（Value）。&lt;/p&gt;

&lt;div class=&quot;language-python highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;
&lt;span class=&quot;n&quot;&gt;a&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;123&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;123&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;456&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;hello&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;a&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;123&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt;    &lt;span class=&quot;c&quot;&gt;# 字典取值，得 123	&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;a&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;456&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;world&quot;&lt;/span&gt;    &lt;span class=&quot;c&quot;&gt;# 字典设置值&lt;/span&gt;

&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;ul&gt;
  &lt;li&gt;字典中的值是可以修改的&lt;/li&gt;
  &lt;li&gt;字典有个特性是：取值和设置值速度非常快&lt;/li&gt;
&lt;/ul&gt;

&lt;h1 id=&quot;字符串&quot;&gt;字符串&lt;/h1&gt;

&lt;p&gt;字符串其实是一个特殊的列表，列表中的每个元素是一个字符&lt;/p&gt;

&lt;h2 id=&quot;字符串替换&quot;&gt;字符串替换&lt;/h2&gt;

&lt;div class=&quot;language-python highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;
&lt;span class=&quot;n&quot;&gt;a&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;hello lilei&quot;&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;a&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[:&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;5&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt;   &lt;span class=&quot;c&quot;&gt;# &quot;hello&quot;，字符串本质上是常量，可以查询，不能修改&lt;/span&gt;

&lt;span class=&quot;n&quot;&gt;a&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;hello &lt;/span&gt;&lt;span class=&quot;si&quot;&gt;%&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;s&quot;&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;%&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;lilei&quot;&lt;/span&gt;    &lt;span class=&quot;c&quot;&gt;# %s 为占位符&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;a&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;si&quot;&gt;%&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;s &lt;/span&gt;&lt;span class=&quot;si&quot;&gt;%&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;s&quot;&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;%&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;hello&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;lilei&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;a&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;si&quot;&gt;%(verb)&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;s &lt;/span&gt;&lt;span class=&quot;si&quot;&gt;%(name)&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;s&quot;&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;%&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;verb&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;hello&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;name&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;lilei&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;    &lt;span class=&quot;c&quot;&gt;# 给占位符起名&lt;/span&gt;

&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h1 id=&quot;元组在函数中的应用&quot;&gt;元组在函数中的应用&lt;/h1&gt;

&lt;p&gt;当一个函数返回多个值的时候，它实际上返回了一个元组。&lt;/p&gt;

&lt;p&gt;一个元组中的多个元素分别赋值给对应的变量称为解包。&lt;/p&gt;

&lt;p&gt;如下：&lt;/p&gt;

&lt;div class=&quot;language-python highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;
&lt;span class=&quot;n&quot;&gt;a&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;b&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;   &lt;span class=&quot;c&quot;&gt;# 元组解包&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;param&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;  &lt;span class=&quot;c&quot;&gt;# 定义一个元组&lt;/span&gt;

&lt;span class=&quot;n&quot;&gt;add&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;*&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;param&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;err&quot;&gt;与&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;add&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;err&quot;&gt;一样，&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;*&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;param&lt;/span&gt; &lt;span class=&quot;err&quot;&gt;对应到了位置参数&lt;/span&gt;

&lt;span class=&quot;err&quot;&gt;可以使用字典来对应关键字参数&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;param&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;a&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;b&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;    &lt;span class=&quot;c&quot;&gt;# 定义一个字典&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;add&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;**&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;param&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;err&quot;&gt;与&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;add&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;a&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;b&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;err&quot;&gt;一样，&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;**&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;param&lt;/span&gt; &lt;span class=&quot;err&quot;&gt;对应到了关键字参数&lt;/span&gt;

&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
</description>
        <pubDate>Wed, 07 Jun 2017 00:00:00 +0800</pubDate>
        <link>http://jaminzhang.me/python/Python-Fundamental-07-Advanced-Data-Type/</link>
        <guid isPermaLink="true">http://jaminzhang.me/python/Python-Fundamental-07-Advanced-Data-Type/</guid>
        
        <category>Python</category>
        
      </item>
    
  </channel>
</rss>
