**筆記名稱:學點Python**
`Tips: English is useful and necessary.`
> 建議:筆記中所有代碼,手動敲一遍,不要復制粘貼。
## **適合人群**
* 已經對Python基本語法有所了解,需要深入學習的入門者
* 適合Python開發者用作手冊,隨時查閱
* 具有其他編程語言基礎的人,可通過本筆記快速上手Python
## **Contents**
* Python 基礎知識
* 數據類型
* 操作符
* 流程控制
* 函數
* 模塊
* 面向對象編程
* 模式匹配與正則表達式
* 讀寫文件
* 異常處理
* 標準庫概覽
* Python 實戰項目
* 控制臺程序
* 實用小工具
* 處理 Excel
* 處理 PDF 與 Word 文檔
* 處理 CSV 文件和 JSON 數據
* 操作圖像
* 網絡爬蟲
* 小游戲
* 微信/小程序
* Web 開發
* 數據分析
* 人工智能
## **Author**
* [隨心而碼](https://linjianming.com/)
* 郵箱:admin@originspace.cn
:-: 覺得有、用,打賞作者
| 微信 | 支付寶 |
| --- | --- |
|  |  |
## **The Zen of Python**
見 [https://www.python.org/dev/peps/pep-0020/](https://www.python.org/dev/peps/pep-0020/)
```python
>>> import this
```
<table style="height: 713px; width: 644px;" border="0"><caption>Python 之禪 中英文對照</caption>
<tbody>
<tr style="background-color: #66cc33;">
<td><b>The Zen of Python, by Tim Peters</b></td>
<td><b>Python之禪 by Tim Peters</b></td>
</tr>
<tr style="background-color: #cbe8ea;">
<td><span style="font-family: 'comic sans ms', sans-serif; font-size: 13px;">Beautiful is better than ugly.</span></td>
<td><span style="font-family: 'comic sans ms', sans-serif; font-size: 13px;">優美勝于丑陋(Python 以編寫優美的代碼為目標)</span></td>
</tr>
<tr style="background-color: #03c9fb;">
<td><span style="font-family: 'comic sans ms', sans-serif; font-size: 13px;">Explicit is better than implicit.</span></td>
<td><span style="font-family: 'comic sans ms', sans-serif; font-size: 13px;">明了勝于晦澀(優美的代碼應當是明了的,命名規范,風格相似)</span></td>
</tr>
<tr style="background-color: #cbe8ea;">
<td><span style="font-family: 'comic sans ms', sans-serif; font-size: 13px;">Simple is better than complex.</span></td>
<td><span style="font-family: 'comic sans ms', sans-serif; font-size: 13px;">簡潔勝于復雜(優美的代碼應當是簡潔的,不要有復雜的內部實現)</span></td>
</tr>
<tr style="background-color: #03c9fb;">
<td><span style="font-family: 'comic sans ms', sans-serif; font-size: 13px;">Complex is better than complicated.</span></td>
<td><span style="font-family: 'comic sans ms', sans-serif; font-size: 13px;">復雜勝于凌亂(如果復雜不可避免,那代碼間也不能有難懂的關系,要保持接口簡潔)</span></td>
</tr>
<tr style="background-color: #cbe8ea;">
<td><span style="font-family: 'comic sans ms', sans-serif; font-size: 13px;">Flat is better than nested.</span></td>
<td><span style="font-family: 'comic sans ms', sans-serif; font-size: 13px;"> 扁平勝于嵌套(優美的代碼應當是扁平的,不能有太多的嵌套)</span></td>
</tr>
<tr style="background-color: #03c9fb;">
<td><span style="font-family: 'comic sans ms', sans-serif; font-size: 13px;">Sparse is better than dense.</span></td>
<td><span style="font-family: 'comic sans ms', sans-serif; font-size: 13px;"> 間隔勝于緊湊(優美的代碼有適當的間隔,不要奢望一行代碼解決問題)</span></td>
</tr>
<tr style="background-color: #cbe8ea;">
<td><span style="font-family: 'comic sans ms', sans-serif; font-size: 13px;">Readability counts.</span></td>
<td><span style="font-family: 'comic sans ms', sans-serif; font-size: 13px;"> 可讀性很重要(優美的代碼是可讀的)</span></td>
</tr>
<tr style="background-color: #03c9fb;">
<td><span style="font-family: 'comic sans ms', sans-serif; font-size: 13px;">Special cases aren't special enough to break the rules.Although practicality beats purity.</span></td>
<td><span style="font-family: 'comic sans ms', sans-serif; font-size: 13px;"> 即便假借特例的實用性之名,也不可違背這些規則(這些規則至高無上)</span></td>
</tr>
<tr style="background-color: #cbe8ea;">
<td><span style="font-family: 'comic sans ms', sans-serif; font-size: 13px;">Errors should never pass silently.Unless explicitly silenced.</span></td>
<td><span style="font-family: 'comic sans ms', sans-serif; font-size: 13px;"> 不要包容所有錯誤,除非你確定需要這樣做(精準地捕獲異常,不寫 except:pass 風格的代碼)</span></td>
</tr>
<tr style="background-color: #03c9fb;">
<td><span style="font-family: 'comic sans ms', sans-serif; font-size: 13px;">In the face of ambiguity, refuse the temptation to guess.</span></td>
<td><span style="font-family: 'comic sans ms', sans-serif; font-size: 13px;"> 當存在多種可能,不要嘗試去猜測</span></td>
</tr>
<tr style="background-color: #cbe8ea;">
<td><span style="font-family: 'comic sans ms', sans-serif; font-size: 13px;">There should be one-- and preferably only one --obvious way to do it.</span></td>
<td><span style="font-family: 'comic sans ms', sans-serif; font-size: 13px;"> 而是盡量找一種,最好是唯一一種明顯的解決方案(如果不確定,就用窮舉法)</span></td>
</tr>
<tr style="background-color: #03c9fb;">
<td><span style="font-family: 'comic sans ms', sans-serif; font-size: 13px;">Although that way may not be obvious at first unless you're Dutch.</span></td>
<td><span style="font-family: 'comic sans ms', sans-serif; font-size: 13px;"> 雖然這并不容易,因為你不是 Python 之父(這里的 Dutch 是指 Guido )</span></td>
</tr>
<tr style="background-color: #cbe8ea;">
<td><span style="font-family: 'comic sans ms', sans-serif; font-size: 13px;">Now is better than never.Although never is often better than *right* now.</span></td>
<td><span style="font-family: 'comic sans ms', sans-serif; font-size: 13px;"> 做也許好過不做,但不假思索就動手還不如不做(動手之前要細思量)</span></td>
</tr>
<tr style="background-color: #03c9fb;">
<td><span style="font-family: 'comic sans ms', sans-serif; font-size: 13px;">If the implementation is hard to explain, it's a bad idea.If the implementation is easy to explain, it may be a good idea.</span></td>
<td><span style="font-family: 'comic sans ms', sans-serif; font-size: 13px;">如果你無法向人描述你的方案,那肯定不是一個好方案;反之亦然(方案測評標準)</span></td>
</tr>
<tr style="background-color: #cbe8ea;">
<td><span style="font-family: 'comic sans ms', sans-serif; font-size: 13px;">Namespaces are one honking great idea -- let's do more of those!</span></td>
<td><span style="font-family: 'comic sans ms', sans-serif; font-size: 13px;"> 命名空間是一種絕妙的理念,我們應當多加利用(倡導與號召)</span></td>
</tr>
</tbody>
</table>
作者:biyoulin
出處:**[http://www.cnblogs.com/biyoulin/](http://www.cnblogs.com/biyoulin/)**