Skip to content

Commit 188a6a8

Browse files
committed
Python-Basics.ipynb, Python-Constructs.ipynb: 补充 2020 年内容
- 全面使用 f-string - 加入 Python 设计理念小结 - 加入 collections 内容
1 parent 2859de6 commit 188a6a8

File tree

2 files changed

+709
-109
lines changed

2 files changed

+709
-109
lines changed

notebooks/Python-Basics.ipynb

Lines changed: 102 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
" 言,即把不同的程序粘合在一起。\n",
1717
" - Python 是一个通用语言,不仅在科学研究,在生活中的方方面面都会有用。\n",
1818
" - 操作系统生成器和管理器 (Gentoo Portage)\n",
19-
" - 极简的网站服务器 (https://data-contest.net9.org/)"
19+
" - 网站 (Django)"
2020
]
2121
},
2222
{
@@ -58,22 +58,23 @@
5858
"\n",
5959
"```\n",
6060
"$ python3\n",
61-
"Python 3.5.3 (default, Sep 27 2018, 17:25:39)\n",
62-
"[GCC 6.3.0 20170516] on linux\n",
61+
"Python 3.7.3 (default, Dec 20 2019, 18:57:59) \n",
62+
"[GCC 8.3.0] on linux\n",
6363
"Type \"help\", \"copyright\", \"credits\" or \"license\" for more information.\n",
64-
">>>\n",
64+
">>> \n",
6565
"```\n",
6666
"\n",
6767
"### IPython 增强的互动环境\n",
6868
"\n",
6969
"IPython 是一个提供了额外交互功能的环境:\n",
7070
"\n",
7171
"```\n",
72+
"# apt install ipython3\n",
7273
"$ ipython3\n",
73-
"Python 3.5.3 (default, Sep 27 2018, 17:25:39)\n",
74+
"Python 3.7.3 (default, Dec 20 2019, 18:57:59) \n",
7475
"Type \"copyright\", \"credits\" or \"license\" for more information.\n",
7576
"\n",
76-
"IPython 5.1.0 -- An enhanced Interactive Python.\n",
77+
"IPython 5.8.0 -- An enhanced Interactive Python.\n",
7778
"? -> Introduction and overview of IPython's features.\n",
7879
"%quickref -> Quick reference.\n",
7980
"help -> Python's own help system.\n",
@@ -85,7 +86,7 @@
8586
},
8687
{
8788
"cell_type": "code",
88-
"execution_count": 3,
89+
"execution_count": 1,
8990
"metadata": {
9091
"slideshow": {
9192
"slide_type": "subslide"
@@ -95,10 +96,10 @@
9596
{
9697
"data": {
9798
"text/plain": [
98-
"'3.6.5 (default, Apr 25 2018, 20:23:05) \\n[GCC 6.4.0]'"
99+
"'3.6.10 (default, Apr 17 2020, 18:23:05) \\n[GCC 9.2.0]'"
99100
]
100101
},
101-
"execution_count": 3,
102+
"execution_count": 1,
102103
"metadata": {},
103104
"output_type": "execute_result"
104105
}
@@ -687,6 +688,46 @@
687688
"与高精度整数一样,字符串也没有硬件的对应,是 Python 的软件实现。这极大方便了使用 Python 进行文本处理。"
688689
]
689690
},
691+
{
692+
"cell_type": "code",
693+
"execution_count": 9,
694+
"metadata": {},
695+
"outputs": [
696+
{
697+
"data": {
698+
"text/plain": [
699+
"'今天下雨了'"
700+
]
701+
},
702+
"execution_count": 9,
703+
"metadata": {},
704+
"output_type": "execute_result"
705+
}
706+
],
707+
"source": [
708+
"\"今天\" + \"下雨了\""
709+
]
710+
},
711+
{
712+
"cell_type": "code",
713+
"execution_count": 10,
714+
"metadata": {},
715+
"outputs": [
716+
{
717+
"data": {
718+
"text/plain": [
719+
"'12'"
720+
]
721+
},
722+
"execution_count": 10,
723+
"metadata": {},
724+
"output_type": "execute_result"
725+
}
726+
],
727+
"source": [
728+
"\"1\" + \"2\""
729+
]
730+
},
690731
{
691732
"cell_type": "markdown",
692733
"metadata": {
@@ -695,7 +736,7 @@
695736
}
696737
},
697738
"source": [
698-
"## 入门\n",
739+
"## 入门 Python\n",
699740
"输出\"Hello World!\""
700741
]
701742
},
@@ -733,7 +774,7 @@
733774
},
734775
{
735776
"cell_type": "code",
736-
"execution_count": 74,
777+
"execution_count": 3,
737778
"metadata": {},
738779
"outputs": [
739780
{
@@ -748,13 +789,61 @@
748789
"message = \"This is an new era. 新时代\"\n",
749790
"print(message)"
750791
]
792+
},
793+
{
794+
"cell_type": "markdown",
795+
"metadata": {
796+
"slideshow": {
797+
"slide_type": "slide"
798+
}
799+
},
800+
"source": [
801+
"## 标准输入输出\n",
802+
"\n",
803+
"- 标准输出默认与屏幕连接,`print()` 默认向标准输出写\n",
804+
"- 标准输入默认与键盘连接,`input()` 默认从标准输入读"
805+
]
806+
},
807+
{
808+
"cell_type": "code",
809+
"execution_count": 7,
810+
"metadata": {},
811+
"outputs": [
812+
{
813+
"name": "stdout",
814+
"output_type": "stream",
815+
"text": [
816+
"Who am I?\n"
817+
]
818+
}
819+
],
820+
"source": [
821+
"q = input() # 下面由现场输入"
822+
]
823+
},
824+
{
825+
"cell_type": "code",
826+
"execution_count": 8,
827+
"metadata": {},
828+
"outputs": [
829+
{
830+
"name": "stdout",
831+
"output_type": "stream",
832+
"text": [
833+
"Who am I?\n"
834+
]
835+
}
836+
],
837+
"source": [
838+
"print(q)"
839+
]
751840
}
752841
],
753842
"metadata": {
754843
"celltoolbar": "Slideshow",
755844
"kernelspec": {
756845
"display_name": "Python 3",
757-
"language": "python3",
846+
"language": "python",
758847
"name": "python3"
759848
},
760849
"language_info": {
@@ -767,7 +856,7 @@
767856
"name": "python",
768857
"nbconvert_exporter": "python",
769858
"pygments_lexer": "ipython3",
770-
"version": "3.6.5"
859+
"version": "3.6.10"
771860
}
772861
},
773862
"nbformat": 4,

0 commit comments

Comments
 (0)