forked from lijin-THU/notes-python
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Former-commit-id: ce43172 Former-commit-id: 253748d5546d2c73d36658afbbf8d62711a40d59 [formerly 1c9f2e3fa4fa463c96e2fbbcf72f49e01c27941c] [formerly 262288ad0cdc8898db36febedfdef123c9a71147 [formerly 38acd3d]] Former-commit-id: 1bb456ca385cfebc0546e191770c2ddef4a0b9a4 [formerly 42d77d785c581f94b31fd4f1931af4d965d43c03] Former-commit-id: 8f3ecb61ec359e41b3b082aafc959cf52bbffd6a Former-commit-id: 7a4ac7f84b160504b19ebaaa37b292e253b39f30 [formerly f449f5453474eeee15de89c106066054b56c15a4] [formerly d733a386a045d57e8efd2db0b80b525b9b057271 [formerly 52f8eb481443b620b7ca103f19c534f7d3450edc]] [formerly 380a45a4dc6bafb5c9fc7b590178474074680ef7 [formerly cc656f1430d72e453205f9129ad4e78dfb77ebf2] [formerly 0b04a4722577bd7374ef3db19116d74fe05a7dc6 [formerly ebbb0a6df197f19f324afabbb0ff019c83c4eafb]]] [formerly e4f7b4bdbe04b3d672d00abf627f691870f7ad23 [formerly 40f49894d465dcca9e94deaffcf9bba56cc01a1e] [formerly 16b28401451747df10de9ee1a48d8e2b3f4b2f0d [formerly d8a5289c5170919ee021ae77a14ee73d0d0ddc61]] [formerly eac5cdfc13ee61766605889f6ac0c4b142f08221 [formerly 644c9a0e949cccbc6eea6c09ea4e782c7300e2e5] [formerly 136b1b00c9894d1d14c61cccde7302aab5bf5746 [formerly c4a5fdd]]]] Former-commit-id: d5263b595d4eb025f80c9e8151dcc434e0d4d0cd [formerly d3ed2675a7a9278803000396b3a14c55c48ad4cc] [formerly 821b0d9c11434bf92a41fabc00914fec3913df98 [formerly 03fd7935c8b6655dbf5c941b05b6be51e8caa23e]] [formerly f3bf16892c522baba47810be87fcf6ef4dc8de11 [formerly b639fcd18cdad66e9df4d8698bcbdcbfbfbf2f30] [formerly 36241e09f6b41416204f8bb0c2d351a4aca38a37 [formerly 0a74bd5c609ca6ed34758f01d9fccc2033a5b3fc]]] Former-commit-id: 9357c2bee7ce979c8c2f5bd1d2b8ea93ddc5cb17 [formerly 2087f57915ad632cd9787e7bffdc9d7b8b150195] [formerly 38c10bc420a2f8da11c46b3758156298f56bc0cf [formerly 28d58c96f4e08147eee0f3dbdfad0983a17cb94d]] Former-commit-id: 8972d4de5e7bdcde4d1b58c8ceb316ed983e755a [formerly 8ab1ce6cb05f558ff67131f607ba3210e0813122] Former-commit-id: 4fe021da62ff5fadffa7a00c26732d0c92289b08
- Loading branch information
Showing
295 changed files
with
92,904 additions
and
155 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,3 +5,4 @@ | |
/*/mnist/* | ||
static files/* | ||
/*/novels/* | ||
/*/*.model |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,243 @@ | ||
{ | ||
"cells": [ | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": { | ||
"collapsed": true | ||
}, | ||
"source": [ | ||
"# Python 简介" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"## **Python** 历史" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"`Python` 的创始人为荷兰人吉多·范罗苏姆(`Guido van Rossum`)。1989年的圣诞节期间,吉多·范罗苏姆为了在阿姆斯特丹打发时间,决心开发一个新的脚本解释程序,作为 ABC 语言的一种继承。之所以选中 `Python` 作为程序的名字,是因为他是 BBC 电视剧——蒙提·派森的飞行马戏团(`Monty Python's Flying Circus`)的爱好者。\n", | ||
"\n", | ||
"1991年,第一个 Python 编译器诞生。它是用C语言实现的,并能够调用C语言的库文件。\n", | ||
"\n", | ||
"`Python 2.0` 于 2000 年 10 月 16 日发布,增加了实现完整的垃圾回收,并且支持 `Unicode`。\n", | ||
"\n", | ||
"`Python 3.0` 于 2008 年 12 月 3 日发布,此版不完全兼容之前的 `Python` 源代码。不过,很多新特性后来也被移植到旧的 `Python 2.6/2.7` 版本。" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"## 第一行Python代码" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"安装好 `Python` 之后,在命令行下输入:\n", | ||
"\n", | ||
" python\n", | ||
"\n", | ||
"就可以进入 `Python` 解释器的页面。\n", | ||
"\n", | ||
"按照惯例,第一行代码应该是输出 `\"hello world!\"`:" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 1, | ||
"metadata": { | ||
"collapsed": false | ||
}, | ||
"outputs": [ | ||
{ | ||
"name": "stdout", | ||
"output_type": "stream", | ||
"text": [ | ||
"hello world!\n" | ||
] | ||
} | ||
], | ||
"source": [ | ||
"print \"hello world!\"" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"相对与 `Java,C` 等语言,`Python` 仅仅使用一行语句就完成的了这个任务。\n", | ||
"\n", | ||
"可以将这句话的内容保存到一个文本文件中,并使用后缀名 `.py` 结尾,例如 `hello_world.py`,在命令行下运行这个程序:\n", | ||
"\n", | ||
" python hello_world.py\n", | ||
"\n", | ||
"也会输出 `\"hello world!\"` 的结果。" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"## Python 之禅" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"在 **Python** 解释器下输入 \n", | ||
"\n", | ||
"```import this```\n", | ||
"\n", | ||
"会出来这样一首小诗:" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 2, | ||
"metadata": { | ||
"collapsed": false | ||
}, | ||
"outputs": [ | ||
{ | ||
"name": "stdout", | ||
"output_type": "stream", | ||
"text": [ | ||
"The Zen of Python, by Tim Peters\n", | ||
"\n", | ||
"Beautiful is better than ugly.\n", | ||
"Explicit is better than implicit.\n", | ||
"Simple is better than complex.\n", | ||
"Complex is better than complicated.\n", | ||
"Flat is better than nested.\n", | ||
"Sparse is better than dense.\n", | ||
"Readability counts.\n", | ||
"Special cases aren't special enough to break the rules.\n", | ||
"Although practicality beats purity.\n", | ||
"Errors should never pass silently.\n", | ||
"Unless explicitly silenced.\n", | ||
"In the face of ambiguity, refuse the temptation to guess.\n", | ||
"There should be one-- and preferably only one --obvious way to do it.\n", | ||
"Although that way may not be obvious at first unless you're Dutch.\n", | ||
"Now is better than never.\n", | ||
"Although never is often better than *right* now.\n", | ||
"If the implementation is hard to explain, it's a bad idea.\n", | ||
"If the implementation is easy to explain, it may be a good idea.\n", | ||
"Namespaces are one honking great idea -- let's do more of those!\n" | ||
] | ||
} | ||
], | ||
"source": [ | ||
"import this" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"这首诗反映了**Python**的设计哲学——**Python**是一种追求优雅,明确,简单的编程语言,但事实上,产生这首诗的代码并没有写的那么简单易懂:" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 3, | ||
"metadata": { | ||
"collapsed": false | ||
}, | ||
"outputs": [ | ||
{ | ||
"name": "stdout", | ||
"output_type": "stream", | ||
"text": [ | ||
"The Zen of Python, by Tim Peters\n", | ||
"\n", | ||
"Beautiful is better than ugly.\n", | ||
"Explicit is better than implicit.\n", | ||
"Simple is better than complex.\n", | ||
"Complex is better than complicated.\n", | ||
"Flat is better than nested.\n", | ||
"Sparse is better than dense.\n", | ||
"Readability counts.\n", | ||
"Special cases aren't special enough to break the rules.\n", | ||
"Although practicality beats purity.\n", | ||
"Errors should never pass silently.\n", | ||
"Unless explicitly silenced.\n", | ||
"In the face of ambiguity, refuse the temptation to guess.\n", | ||
"There should be one-- and preferably only one --obvious way to do it.\n", | ||
"Although that way may not be obvious at first unless you're Dutch.\n", | ||
"Now is better than never.\n", | ||
"Although never is often better than *right* now.\n", | ||
"If the implementation is hard to explain, it's a bad idea.\n", | ||
"If the implementation is easy to explain, it may be a good idea.\n", | ||
"Namespaces are one honking great idea -- let's do more of those!\n" | ||
] | ||
} | ||
], | ||
"source": [ | ||
"s = \"\"\"Gur Mra bs Clguba, ol Gvz Crgref\n", | ||
"\n", | ||
"Ornhgvshy vf orggre guna htyl.\n", | ||
"Rkcyvpvg vf orggre guna vzcyvpvg.\n", | ||
"Fvzcyr vf orggre guna pbzcyrk.\n", | ||
"Pbzcyrk vf orggre guna pbzcyvpngrq.\n", | ||
"Syng vf orggre guna arfgrq.\n", | ||
"Fcnefr vf orggre guna qrafr.\n", | ||
"Ernqnovyvgl pbhagf.\n", | ||
"Fcrpvny pnfrf nera'g fcrpvny rabhtu gb oernx gur ehyrf.\n", | ||
"Nygubhtu cenpgvpnyvgl orngf chevgl.\n", | ||
"Reebef fubhyq arire cnff fvyragyl.\n", | ||
"Hayrff rkcyvpvgyl fvyraprq.\n", | ||
"Va gur snpr bs nzovthvgl, ershfr gur grzcgngvba gb thrff.\n", | ||
"Gurer fubhyq or bar-- naq cersrenoyl bayl bar --boivbhf jnl gb qb vg.\n", | ||
"Nygubhtu gung jnl znl abg or boivbhf ng svefg hayrff lbh'er Qhgpu.\n", | ||
"Abj vf orggre guna arire.\n", | ||
"Nygubhtu arire vf bsgra orggre guna *evtug* abj.\n", | ||
"Vs gur vzcyrzragngvba vf uneq gb rkcynva, vg'f n onq vqrn.\n", | ||
"Vs gur vzcyrzragngvba vf rnfl gb rkcynva, vg znl or n tbbq vqrn.\n", | ||
"Anzrfcnprf ner bar ubaxvat terng vqrn -- yrg'f qb zber bs gubfr!\"\"\"\n", | ||
"\n", | ||
"d = {}\n", | ||
"for c in (65, 97):\n", | ||
" for i in range(26):\n", | ||
" d[chr(i+c)] = chr((i+13) % 26 + c)\n", | ||
"\n", | ||
"print \"\".join([d.get(c, c) for c in s])" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"> Life is short. Use Python." | ||
] | ||
} | ||
], | ||
"metadata": { | ||
"kernelspec": { | ||
"display_name": "Python 2", | ||
"language": "python", | ||
"name": "python2" | ||
}, | ||
"language_info": { | ||
"codemirror_mode": { | ||
"name": "ipython", | ||
"version": 2 | ||
}, | ||
"file_extension": ".py", | ||
"mimetype": "text/x-python", | ||
"name": "python", | ||
"nbconvert_exporter": "python", | ||
"pygments_lexer": "ipython2", | ||
"version": "2.7.6" | ||
} | ||
}, | ||
"nbformat": 4, | ||
"nbformat_minor": 0 | ||
} |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.