Compare commits

2 Commits
main ... v2

Author SHA1 Message Date
anine09
5570cc5e5a 新年快乐 2024-01-10 03:58:30 +08:00
anine09
f2eab623fa init v2 textbook 2023-09-18 00:05:23 +08:00
33 changed files with 2974 additions and 5277 deletions

39
.github/ISSUE_TEMPLATE/bug.yaml vendored Normal file
View File

@@ -0,0 +1,39 @@
name: 🐞 课程内容错误 / Bugs
description: 在此报告课程中发现的任何错误,以便教学团队及时勘误。
title: "格式:'章节名(Chap 3 | Talks 1): Bugs 概要标题'"
assignees:
- anine09
labels: "反馈问题"
body:
- type: markdown
attributes:
value: |
👏感谢你为 P2S 项目报告错误做出的贡献,为了便于我们了解你的问题,请填写以下信息~
- type: textarea
id: number
attributes:
label: "章节编号"
description: "请填写错误出现的章节号(Chap X | Talks X)"
validations:
required: true
- type: textarea
id: location
attributes:
label: "具体内容"
description: "请粘贴/描述/贴图错误的具体内容位置,方便我们排查~"
validations:
required: true
- type: textarea
id: reason
attributes:
label: "错误描述"
description: "请描述一下这个错误的出错原因~"
validations:
required: true
- type: textarea
id: suggestion
attributes:
label: "改进建议"
description: "请说明改进建议方案,感谢你为 P2S 项目做出的贡献~"
validations:
required: false

5
.github/ISSUE_TEMPLATE/config.yml vendored Normal file
View File

@@ -0,0 +1,5 @@
blank_issues_enabled: true
contact_links:
- name: 💬 参与讨论
url: https://github.com/datawhalechina/learn-python-the-smart-way-v2/discussions
about: issues 暂时只接收教程内容问题反馈(内容错误、改进提案等),在教程学习过程中遇到的其他任何问题,欢迎移步到 Datawhale 聪明办法学 Python 社区的讨论。

43
.github/workflows/ci.yml vendored Normal file
View File

@@ -0,0 +1,43 @@
name: Build and Deploy Docs
on:
push:
branches:
- main
jobs:
build-docs:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: 3.11
- name: Install dependencies
run: |
pip install -r requirements.txt
- name: Build documentation
run: sphinx-build ./notebook docs
- name: Setup Git
run: |
git config user.name "GitHub Action"
git config user.email "action@github.com"
- name: Commit changes
run: |
git add -f ./docs
git commit -m "Build Docs"
- name: Push changes
uses: ad-m/github-push-action@master
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
branch: ${{ github.ref }}

16
.gitignore vendored Normal file
View File

@@ -0,0 +1,16 @@
jupyter_execute/
docs/
# momodel
.idea/
*.pyc
*.swp
.DS_Store
.localenv/
datasets/
core.*
results/
_README.ipynb
_OVERVIEW.md
.ipynb_checkpoints/
coding_here.ipynb

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

File diff suppressed because it is too large Load Diff

View File

@@ -1,603 +0,0 @@
{
"cells": [
{
"cell_type": "markdown",
"id": "a870e71d",
"metadata": {},
"source": [
"# Python 文件与模块"
]
},
{
"cell_type": "markdown",
"id": "1257bf93",
"metadata": {},
"source": [
"## 1.4.1 文件"
]
},
{
"cell_type": "markdown",
"id": "77a65ea6",
"metadata": {},
"source": [
"经过几百万年的演化,人类进化出了其他动物没有的“长期记忆”,进而拥有了语言、文化甚至发展出文明,走上了一条未曾设想的道路。在人类大脑中,“短期记忆”由海马体负责,“长期记忆”则由大脑皮层中的额叶负责;在计算机中也同样存在长短期记忆,短期记忆由程序中的变量负责,长期记忆则交给电脑中的文件系统。"
]
},
{
"cell_type": "markdown",
"id": "8199ed32",
"metadata": {},
"source": [
"### 1.4.1.1 Open 函数"
]
},
{
"cell_type": "markdown",
"id": "6638d46b",
"metadata": {},
"source": [
"Python `open( )` 函数用于打开一个文件,并返回文件对象,在对文件进行处理过程都需要使用到这个函数。"
]
},
{
"cell_type": "markdown",
"id": "508c28c5",
"metadata": {},
"source": [
"> 为了测试 Python 中的文件操作,我们先通过命令行在当前目录保存一个内容为 “hello world!” 的 test.txt 文件。\n",
"\n",
"- Mac / Linux: `echo Hello world >> test.txt`\n",
"- Windows: `echo Hello world > test.txt`\n",
"\n",
"<img style=\"float: center;\" src=\"./src/fig41.png\" width=\"50%\"> "
]
},
{
"cell_type": "markdown",
"id": "fd7d8214",
"metadata": {},
"source": [
"`open(file, mode)` 函数主要有 file 和 mode 两个参数,其中 file 为需要读写文件的路径。mode 为读取文件时的模式,常用的模式有以下几个:\n",
"\n",
"- r以字符串的形式读取文件。\n",
"- rb以二进制的形式读取文件。\n",
"- w写入文件。\n",
"- a追加写入文件。\n",
"\n",
"不同模式下返回的文件对象功能也会不同。"
]
},
{
"cell_type": "code",
"execution_count": 3,
"id": "85581df5",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"<class '_io.TextIOWrapper'>\n"
]
}
],
"source": [
"file = open('test.txt', 'r')\n",
"print(type(file))"
]
},
{
"cell_type": "markdown",
"id": "d4297989",
"metadata": {},
"source": [
"### 1.4.1.2 文件对象"
]
},
{
"cell_type": "markdown",
"id": "b2665bee",
"metadata": {},
"source": [
"`open` 函数会返回一个 文件对象。在进行文件操作前,我们首先需要了解文件对象提供了哪些常用的方法:\n",
"\n",
"- `close( )`: 关闭文件\n",
"- 在 r 与 rb 模式下:\n",
" - `read()`: 读取整个文件\n",
" - `readline()`: 读取文件的一行\n",
" - `readlines()`: 读取文件的所有行\n",
"- 在 w 与 a 模式下:\n",
" - `write()`: \n",
" - `writelines()`: "
]
},
{
"cell_type": "markdown",
"id": "0660d622",
"metadata": {},
"source": [
"下面我们通过实例学习这几种方法:"
]
},
{
"cell_type": "code",
"execution_count": 4,
"id": "c42d7de4",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"hello world\n",
"\n"
]
}
],
"source": [
"## 通过 read 方法读取整个文件\n",
"content = file.read()\n",
"print(content)"
]
},
{
"cell_type": "code",
"execution_count": 5,
"id": "0604c0d2",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"\n"
]
}
],
"source": [
"## 通过 readline() 读取文件的一行\n",
"content = file.readline()\n",
"print(content)"
]
},
{
"cell_type": "markdown",
"id": "921fae61",
"metadata": {},
"source": [
"我们发现上面的代码竟然什么也没输出,这是为什么?\n",
"\n",
"你可以理解 open 函数返回的是一个指针,类似于你在 Microsolf Word 文档里编辑文档时闪烁的光标。在执行过 `file.read( )` 操作后,由于读取了整个文件,这个指针已经来到了文件末尾,因此 `file.readline( )` 没有获取到文件的内容。这种情况我们可以通过 close 方法关闭文件后再重新打开。"
]
},
{
"cell_type": "code",
"execution_count": 6,
"id": "7d180532",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"hello world\n",
"\n"
]
}
],
"source": [
"## 关闭之前打开的 test.txt 文件\n",
"file.close()\n",
"## 重新打开\n",
"file = open('test.txt', 'r')\n",
"content = file.readline()\n",
"print(content)"
]
},
{
"cell_type": "markdown",
"id": "1ebaed11",
"metadata": {},
"source": [
"因此在操作文件时,我们一定要注意每次操作结束后,及时通过 `close( )` 方法关闭文件。"
]
},
{
"cell_type": "code",
"execution_count": 7,
"id": "8388fe2d",
"metadata": {},
"outputs": [],
"source": [
"## 以 w 模式打开文件test.txt\n",
"file = open('test.txt', 'w')\n",
"## 创建需要写入的字符串变量 在字符串中 \\n 代表换行(也就是回车)\n",
"content = 'Hello world!\\nHello Python!!\\n'\n",
"## 写入到 test.txt 文件中\n",
"file.write(content)\n",
"## 关闭文件对象\n",
"file.close()"
]
},
{
"cell_type": "markdown",
"id": "a4726843",
"metadata": {},
"source": [
"<img style=\"float: center;\" src=\"./src/fig42.png\" width=\"50%\"> "
]
},
{
"cell_type": "markdown",
"id": "4db4bd05",
"metadata": {},
"source": [
"需要注意在上述操作中w 模式会覆盖之前的文件。如果你想在文件后面追加内容,可以使用 a 模式操作。"
]
},
{
"cell_type": "code",
"execution_count": 8,
"id": "f3352cfd",
"metadata": {},
"outputs": [],
"source": [
"## 以 w 模式打开文件test.txt\n",
"file = open('test.txt', 'a')\n",
"## 创建需要追加的字符串变量\n",
"content = 'Hello smart way!!!'\n",
"## 写入到 test.txt 文件中\n",
"file.write(content)\n",
"## 关闭文件对象\n",
"file.close()"
]
},
{
"cell_type": "markdown",
"id": "01915069",
"metadata": {},
"source": [
"<img style=\"float: center;\" src=\"./src/fig43.png\" width=\"50%\"> "
]
},
{
"cell_type": "markdown",
"id": "4d487fad",
"metadata": {},
"source": [
"## 1.4.2 模块"
]
},
{
"cell_type": "markdown",
"id": "a8bab259",
"metadata": {},
"source": [
"在普罗米修斯为人类带来火种后,人类制造出了各种各样的工具。工具的产生大大提高了人类的生产力,使人类从石器时代步入铁器时代、蒸汽时代以及现在的信息时代。\n",
"\n",
"在之前的学习中,为了更简洁高效地完成任务,我们引入了函数、数据结构以及面向对象编程等工具。但每次我们在这个代码写完后,在下一个代码中只能把代码复制粘贴过去,而模块可以帮助我们把一个代码添加到另一个代码中,真正实现了工具等复用性。"
]
},
{
"cell_type": "markdown",
"id": "ac5aa0a2",
"metadata": {},
"source": [
"编写模块的方式有很多,其中最简单的模块就是创建一个包含很多函数、变量以及类并以 .py 为后缀的文件。下面我们把上一节中实现的 class 类保存在 student.py 文件中:"
]
},
{
"cell_type": "markdown",
"id": "46b45d90",
"metadata": {},
"source": [
"<img style=\"float: center;\" src=\"./src/fig44.png\" width=\"50%\"> "
]
},
{
"cell_type": "markdown",
"id": "575e38db",
"metadata": {},
"source": [
"> 为了方便读者,也可使用下面的代码来直接在当前目录生成 `student.py` 文件。"
]
},
{
"cell_type": "code",
"execution_count": 9,
"id": "bc4a2658",
"metadata": {},
"outputs": [],
"source": [
"file = open('student.py', 'w',encoding=\"utf-8\")\n",
"file.write(\"\"\"class student():\n",
" def __init__(self, name, Math_score, Chinese_score):\n",
" self.name = name\n",
" self.Math_score = Math_score\n",
" self.Chinese_score = Chinese_score\n",
" \n",
" ## repr 函数用于定义对象被输出时的输出结果\n",
" def __repr__(self):\n",
" return str((self.name, self.Math_score, self.Chinese_score))\n",
" \n",
" def change_score(self, course_name, score):\n",
" if course_name == 'Math':\n",
" self.Math_score = score\n",
" elif course_name == 'Chinese':\n",
" self.Chinese_score = score\n",
" else:\n",
" print(course_name, \" course is still not in current system\")\n",
" \n",
" def print_name(self,):\n",
" print(self.name)\n",
" \n",
" name = 'Undefined'\n",
" Math_score = None\n",
" Chinese_score = None\"\"\")\n",
"file.close()"
]
},
{
"cell_type": "markdown",
"id": "ef0e6af7",
"metadata": {},
"source": [
"使用 `import` 关键字可以把一个模块引入到一个程序来使用它的功能。记得在上一节中我们说过一个程序也可以是一个对象,这时 student.py 程序就成了一个对象,而里面的 student 类便成了它的对象变量。"
]
},
{
"cell_type": "code",
"execution_count": 10,
"id": "8de02c29",
"metadata": {},
"outputs": [],
"source": [
"import student"
]
},
{
"cell_type": "code",
"execution_count": 11,
"id": "4c9f7a60",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"('XiaoHu', 65, 55)\n"
]
}
],
"source": [
"xiaohu = student.student('XiaoHu', 65, 55)\n",
"print(xiaohu)"
]
},
{
"cell_type": "markdown",
"id": "2b91e95f",
"metadata": {},
"source": [
"通过 student.py 这个模块,我们不需要重复编写就可以在任何程序中使用 student 类!正是因为有了模块,才使得数据科学中复杂的算法与模型可以封装到模块中,用户只需要使用模块中定义好的函数与类。"
]
},
{
"cell_type": "markdown",
"id": "c422e8ea",
"metadata": {},
"source": [
"当我们只需要模块中的几个函数或类时,也可以采用 `from model_name import xxx` 的写法导入指定部分:"
]
},
{
"cell_type": "code",
"execution_count": 12,
"id": "abf9e578",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"('XiaoHu', 65, 55)\n"
]
}
],
"source": [
"## 仅导入 student 类\n",
"from student import student\n",
"## 这时直接通过类名,不需要使用模块名\n",
"xiaohu = student('XiaoHu', 65, 55)\n",
"print(xiaohu)"
]
},
{
"cell_type": "markdown",
"id": "3024271d",
"metadata": {},
"source": [
"在 Python 中内置了很多标准模块,例如用于数学操作的 math 模块与处理时间的 time 模块:"
]
},
{
"cell_type": "code",
"execution_count": 13,
"id": "323741ef",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"4.174387269895637\n"
]
}
],
"source": [
"import math\n",
"## 通过 math.log 计算数值的对数\n",
"print(math.log(xiaohu.Math_score))"
]
},
{
"cell_type": "code",
"execution_count": 14,
"id": "67f56bad",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Tue Jul 12 21:37:51 2022\n"
]
}
],
"source": [
"import time\n",
"## 通过 time 库中多个方法获取当前时间\n",
"## time.time 获取当前时间的 unix 时间戳\n",
"## time.loacltime 把当前时间的 unix 时间戳按照时区划分\n",
"## time.asctime 把按时区划分的时间戳转化成标准日期格式\n",
"print(time.asctime(time.localtime(time.time())))"
]
},
{
"cell_type": "markdown",
"id": "389616ba",
"metadata": {},
"source": [
"除此之外Python 还有很多标准库值得我们去探索。例如 re 库可以实现字符串正则表达式的匹配random 用来生成随机数urllib 用来访问互联网……"
]
},
{
"cell_type": "markdown",
"id": "77869207",
"metadata": {},
"source": [
"## 1.4.3 练习"
]
},
{
"cell_type": "markdown",
"id": "709140e5",
"metadata": {},
"source": [
"### 1.4.3.1 学生信息本地存储"
]
},
{
"cell_type": "markdown",
"id": "2d0897a3",
"metadata": {},
"source": [
"> 之前我们实现了学生信息的“增删查改”功能,现在希望通过文件系统保存学生的信息,每次打开程序时可以载入,关闭程序时可以保存。"
]
},
{
"cell_type": "markdown",
"id": "f0673d08",
"metadata": {},
"source": [
"### 1.4.3.2 Python 之禅"
]
},
{
"cell_type": "markdown",
"id": "7d95cc3f",
"metadata": {},
"source": [
"<blockquote>\n",
"\n",
"首先在这里恭喜各位同学完成了 Python 的全部学习内容!在这四章中希望你可以体会到本教程简洁明快的风格,这种风格与 Python 本身的代码设计风格是一致的。在 Tim Peters 编写的 “Python 之禅” 中的核心指导原则就是 “Simple is better than complex”。\n",
"\n",
"纵观历史,你会看到苹果创始人史蒂夫·乔布斯对 Less is More 的追求,看到无印良品“删繁就简,去其浮华”的核心设计理念,看到山下英子在《断舍离》中对生活做减法的观点,甚至看到苏东坡“竹杖芒鞋轻胜马,一蓑烟雨任平生”的人生态度。你会发现极简主义不只存在于 Python 编程中,它本就是这个世界优雅的一条运行法则。\n",
" \n",
"本练习让我们导入 this 模块,用心体会一下 Python 的设计原则。\n",
" \n",
"</blockquote>"
]
},
{
"cell_type": "code",
"execution_count": 15,
"id": "d918ee0e",
"metadata": {
"scrolled": 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"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3.9.7 ('base')",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.9.7"
},
"toc": {
"base_numbering": 1,
"nav_menu": {},
"number_sections": false,
"sideBar": true,
"skip_h1_title": false,
"title_cell": "Table of Contents",
"title_sidebar": "Contents",
"toc_cell": false,
"toc_position": {},
"toc_section_display": true,
"toc_window_display": true
},
"vscode": {
"interpreter": {
"hash": "c6e4e9f98eb68ad3b7c296f83d20e6de614cb42e90992a65aa266555a3137d0d"
}
}
},
"nbformat": 4,
"nbformat_minor": 5
}

437
LICENSE
View File

@@ -1,437 +0,0 @@
Attribution-NonCommercial-ShareAlike 4.0 International
=======================================================================
Creative Commons Corporation ("Creative Commons") is not a law firm and
does not provide legal services or legal advice. Distribution of
Creative Commons public licenses does not create a lawyer-client or
other relationship. Creative Commons makes its licenses and related
information available on an "as-is" basis. Creative Commons gives no
warranties regarding its licenses, any material licensed under their
terms and conditions, or any related information. Creative Commons
disclaims all liability for damages resulting from their use to the
fullest extent possible.
Using Creative Commons Public Licenses
Creative Commons public licenses provide a standard set of terms and
conditions that creators and other rights holders may use to share
original works of authorship and other material subject to copyright
and certain other rights specified in the public license below. The
following considerations are for informational purposes only, are not
exhaustive, and do not form part of our licenses.
Considerations for licensors: Our public licenses are
intended for use by those authorized to give the public
permission to use material in ways otherwise restricted by
copyright and certain other rights. Our licenses are
irrevocable. Licensors should read and understand the terms
and conditions of the license they choose before applying it.
Licensors should also secure all rights necessary before
applying our licenses so that the public can reuse the
material as expected. Licensors should clearly mark any
material not subject to the license. This includes other CC-
licensed material, or material used under an exception or
limitation to copyright. More considerations for licensors:
wiki.creativecommons.org/Considerations_for_licensors
Considerations for the public: By using one of our public
licenses, a licensor grants the public permission to use the
licensed material under specified terms and conditions. If
the licensor's permission is not necessary for any reason--for
example, because of any applicable exception or limitation to
copyright--then that use is not regulated by the license. Our
licenses grant only permissions under copyright and certain
other rights that a licensor has authority to grant. Use of
the licensed material may still be restricted for other
reasons, including because others have copyright or other
rights in the material. A licensor may make special requests,
such as asking that all changes be marked or described.
Although not required by our licenses, you are encouraged to
respect those requests where reasonable. More considerations
for the public:
wiki.creativecommons.org/Considerations_for_licensees
=======================================================================
Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International
Public License
By exercising the Licensed Rights (defined below), You accept and agree
to be bound by the terms and conditions of this Creative Commons
Attribution-NonCommercial-ShareAlike 4.0 International Public License
("Public License"). To the extent this Public License may be
interpreted as a contract, You are granted the Licensed Rights in
consideration of Your acceptance of these terms and conditions, and the
Licensor grants You such rights in consideration of benefits the
Licensor receives from making the Licensed Material available under
these terms and conditions.
Section 1 -- Definitions.
a. Adapted Material means material subject to Copyright and Similar
Rights that is derived from or based upon the Licensed Material
and in which the Licensed Material is translated, altered,
arranged, transformed, or otherwise modified in a manner requiring
permission under the Copyright and Similar Rights held by the
Licensor. For purposes of this Public License, where the Licensed
Material is a musical work, performance, or sound recording,
Adapted Material is always produced where the Licensed Material is
synched in timed relation with a moving image.
b. Adapter's License means the license You apply to Your Copyright
and Similar Rights in Your contributions to Adapted Material in
accordance with the terms and conditions of this Public License.
c. BY-NC-SA Compatible License means a license listed at
creativecommons.org/compatiblelicenses, approved by Creative
Commons as essentially the equivalent of this Public License.
d. Copyright and Similar Rights means copyright and/or similar rights
closely related to copyright including, without limitation,
performance, broadcast, sound recording, and Sui Generis Database
Rights, without regard to how the rights are labeled or
categorized. For purposes of this Public License, the rights
specified in Section 2(b)(1)-(2) are not Copyright and Similar
Rights.
e. Effective Technological Measures means those measures that, in the
absence of proper authority, may not be circumvented under laws
fulfilling obligations under Article 11 of the WIPO Copyright
Treaty adopted on December 20, 1996, and/or similar international
agreements.
f. Exceptions and Limitations means fair use, fair dealing, and/or
any other exception or limitation to Copyright and Similar Rights
that applies to Your use of the Licensed Material.
g. License Elements means the license attributes listed in the name
of a Creative Commons Public License. The License Elements of this
Public License are Attribution, NonCommercial, and ShareAlike.
h. Licensed Material means the artistic or literary work, database,
or other material to which the Licensor applied this Public
License.
i. Licensed Rights means the rights granted to You subject to the
terms and conditions of this Public License, which are limited to
all Copyright and Similar Rights that apply to Your use of the
Licensed Material and that the Licensor has authority to license.
j. Licensor means the individual(s) or entity(ies) granting rights
under this Public License.
k. NonCommercial means not primarily intended for or directed towards
commercial advantage or monetary compensation. For purposes of
this Public License, the exchange of the Licensed Material for
other material subject to Copyright and Similar Rights by digital
file-sharing or similar means is NonCommercial provided there is
no payment of monetary compensation in connection with the
exchange.
l. Share means to provide material to the public by any means or
process that requires permission under the Licensed Rights, such
as reproduction, public display, public performance, distribution,
dissemination, communication, or importation, and to make material
available to the public including in ways that members of the
public may access the material from a place and at a time
individually chosen by them.
m. Sui Generis Database Rights means rights other than copyright
resulting from Directive 96/9/EC of the European Parliament and of
the Council of 11 March 1996 on the legal protection of databases,
as amended and/or succeeded, as well as other essentially
equivalent rights anywhere in the world.
n. You means the individual or entity exercising the Licensed Rights
under this Public License. Your has a corresponding meaning.
Section 2 -- Scope.
a. License grant.
1. Subject to the terms and conditions of this Public License,
the Licensor hereby grants You a worldwide, royalty-free,
non-sublicensable, non-exclusive, irrevocable license to
exercise the Licensed Rights in the Licensed Material to:
a. reproduce and Share the Licensed Material, in whole or
in part, for NonCommercial purposes only; and
b. produce, reproduce, and Share Adapted Material for
NonCommercial purposes only.
2. Exceptions and Limitations. For the avoidance of doubt, where
Exceptions and Limitations apply to Your use, this Public
License does not apply, and You do not need to comply with
its terms and conditions.
3. Term. The term of this Public License is specified in Section
6(a).
4. Media and formats; technical modifications allowed. The
Licensor authorizes You to exercise the Licensed Rights in
all media and formats whether now known or hereafter created,
and to make technical modifications necessary to do so. The
Licensor waives and/or agrees not to assert any right or
authority to forbid You from making technical modifications
necessary to exercise the Licensed Rights, including
technical modifications necessary to circumvent Effective
Technological Measures. For purposes of this Public License,
simply making modifications authorized by this Section 2(a)
(4) never produces Adapted Material.
5. Downstream recipients.
a. Offer from the Licensor -- Licensed Material. Every
recipient of the Licensed Material automatically
receives an offer from the Licensor to exercise the
Licensed Rights under the terms and conditions of this
Public License.
b. Additional offer from the Licensor -- Adapted Material.
Every recipient of Adapted Material from You
automatically receives an offer from the Licensor to
exercise the Licensed Rights in the Adapted Material
under the conditions of the Adapter's License You apply.
c. No downstream restrictions. You may not offer or impose
any additional or different terms or conditions on, or
apply any Effective Technological Measures to, the
Licensed Material if doing so restricts exercise of the
Licensed Rights by any recipient of the Licensed
Material.
6. No endorsement. Nothing in this Public License constitutes or
may be construed as permission to assert or imply that You
are, or that Your use of the Licensed Material is, connected
with, or sponsored, endorsed, or granted official status by,
the Licensor or others designated to receive attribution as
provided in Section 3(a)(1)(A)(i).
b. Other rights.
1. Moral rights, such as the right of integrity, are not
licensed under this Public License, nor are publicity,
privacy, and/or other similar personality rights; however, to
the extent possible, the Licensor waives and/or agrees not to
assert any such rights held by the Licensor to the limited
extent necessary to allow You to exercise the Licensed
Rights, but not otherwise.
2. Patent and trademark rights are not licensed under this
Public License.
3. To the extent possible, the Licensor waives any right to
collect royalties from You for the exercise of the Licensed
Rights, whether directly or through a collecting society
under any voluntary or waivable statutory or compulsory
licensing scheme. In all other cases the Licensor expressly
reserves any right to collect such royalties, including when
the Licensed Material is used other than for NonCommercial
purposes.
Section 3 -- License Conditions.
Your exercise of the Licensed Rights is expressly made subject to the
following conditions.
a. Attribution.
1. If You Share the Licensed Material (including in modified
form), You must:
a. retain the following if it is supplied by the Licensor
with the Licensed Material:
i. identification of the creator(s) of the Licensed
Material and any others designated to receive
attribution, in any reasonable manner requested by
the Licensor (including by pseudonym if
designated);
ii. a copyright notice;
iii. a notice that refers to this Public License;
iv. a notice that refers to the disclaimer of
warranties;
v. a URI or hyperlink to the Licensed Material to the
extent reasonably practicable;
b. indicate if You modified the Licensed Material and
retain an indication of any previous modifications; and
c. indicate the Licensed Material is licensed under this
Public License, and include the text of, or the URI or
hyperlink to, this Public License.
2. You may satisfy the conditions in Section 3(a)(1) in any
reasonable manner based on the medium, means, and context in
which You Share the Licensed Material. For example, it may be
reasonable to satisfy the conditions by providing a URI or
hyperlink to a resource that includes the required
information.
3. If requested by the Licensor, You must remove any of the
information required by Section 3(a)(1)(A) to the extent
reasonably practicable.
b. ShareAlike.
In addition to the conditions in Section 3(a), if You Share
Adapted Material You produce, the following conditions also apply.
1. The Adapter's License You apply must be a Creative Commons
license with the same License Elements, this version or
later, or a BY-NC-SA Compatible License.
2. You must include the text of, or the URI or hyperlink to, the
Adapter's License You apply. You may satisfy this condition
in any reasonable manner based on the medium, means, and
context in which You Share Adapted Material.
3. You may not offer or impose any additional or different terms
or conditions on, or apply any Effective Technological
Measures to, Adapted Material that restrict exercise of the
rights granted under the Adapter's License You apply.
Section 4 -- Sui Generis Database Rights.
Where the Licensed Rights include Sui Generis Database Rights that
apply to Your use of the Licensed Material:
a. for the avoidance of doubt, Section 2(a)(1) grants You the right
to extract, reuse, reproduce, and Share all or a substantial
portion of the contents of the database for NonCommercial purposes
only;
b. if You include all or a substantial portion of the database
contents in a database in which You have Sui Generis Database
Rights, then the database in which You have Sui Generis Database
Rights (but not its individual contents) is Adapted Material,
including for purposes of Section 3(b); and
c. You must comply with the conditions in Section 3(a) if You Share
all or a substantial portion of the contents of the database.
For the avoidance of doubt, this Section 4 supplements and does not
replace Your obligations under this Public License where the Licensed
Rights include other Copyright and Similar Rights.
Section 5 -- Disclaimer of Warranties and Limitation of Liability.
a. UNLESS OTHERWISE SEPARATELY UNDERTAKEN BY THE LICENSOR, TO THE
EXTENT POSSIBLE, THE LICENSOR OFFERS THE LICENSED MATERIAL AS-IS
AND AS-AVAILABLE, AND MAKES NO REPRESENTATIONS OR WARRANTIES OF
ANY KIND CONCERNING THE LICENSED MATERIAL, WHETHER EXPRESS,
IMPLIED, STATUTORY, OR OTHER. THIS INCLUDES, WITHOUT LIMITATION,
WARRANTIES OF TITLE, MERCHANTABILITY, FITNESS FOR A PARTICULAR
PURPOSE, NON-INFRINGEMENT, ABSENCE OF LATENT OR OTHER DEFECTS,
ACCURACY, OR THE PRESENCE OR ABSENCE OF ERRORS, WHETHER OR NOT
KNOWN OR DISCOVERABLE. WHERE DISCLAIMERS OF WARRANTIES ARE NOT
ALLOWED IN FULL OR IN PART, THIS DISCLAIMER MAY NOT APPLY TO YOU.
b. TO THE EXTENT POSSIBLE, IN NO EVENT WILL THE LICENSOR BE LIABLE
TO YOU ON ANY LEGAL THEORY (INCLUDING, WITHOUT LIMITATION,
NEGLIGENCE) OR OTHERWISE FOR ANY DIRECT, SPECIAL, INDIRECT,
INCIDENTAL, CONSEQUENTIAL, PUNITIVE, EXEMPLARY, OR OTHER LOSSES,
COSTS, EXPENSES, OR DAMAGES ARISING OUT OF THIS PUBLIC LICENSE OR
USE OF THE LICENSED MATERIAL, EVEN IF THE LICENSOR HAS BEEN
ADVISED OF THE POSSIBILITY OF SUCH LOSSES, COSTS, EXPENSES, OR
DAMAGES. WHERE A LIMITATION OF LIABILITY IS NOT ALLOWED IN FULL OR
IN PART, THIS LIMITATION MAY NOT APPLY TO YOU.
c. The disclaimer of warranties and limitation of liability provided
above shall be interpreted in a manner that, to the extent
possible, most closely approximates an absolute disclaimer and
waiver of all liability.
Section 6 -- Term and Termination.
a. This Public License applies for the term of the Copyright and
Similar Rights licensed here. However, if You fail to comply with
this Public License, then Your rights under this Public License
terminate automatically.
b. Where Your right to use the Licensed Material has terminated under
Section 6(a), it reinstates:
1. automatically as of the date the violation is cured, provided
it is cured within 30 days of Your discovery of the
violation; or
2. upon express reinstatement by the Licensor.
For the avoidance of doubt, this Section 6(b) does not affect any
right the Licensor may have to seek remedies for Your violations
of this Public License.
c. For the avoidance of doubt, the Licensor may also offer the
Licensed Material under separate terms or conditions or stop
distributing the Licensed Material at any time; however, doing so
will not terminate this Public License.
d. Sections 1, 5, 6, 7, and 8 survive termination of this Public
License.
Section 7 -- Other Terms and Conditions.
a. The Licensor shall not be bound by any additional or different
terms or conditions communicated by You unless expressly agreed.
b. Any arrangements, understandings, or agreements regarding the
Licensed Material not stated herein are separate from and
independent of the terms and conditions of this Public License.
Section 8 -- Interpretation.
a. For the avoidance of doubt, this Public License does not, and
shall not be interpreted to, reduce, limit, restrict, or impose
conditions on any use of the Licensed Material that could lawfully
be made without permission under this Public License.
b. To the extent possible, if any provision of this Public License is
deemed unenforceable, it shall be automatically reformed to the
minimum extent necessary to make it enforceable. If the provision
cannot be reformed, it shall be severed from this Public License
without affecting the enforceability of the remaining terms and
conditions.
c. No term or condition of this Public License will be waived and no
failure to comply consented to unless expressly agreed to by the
Licensor.
d. Nothing in this Public License constitutes or may be interpreted
as a limitation upon, or waiver of, any privileges and immunities
that apply to the Licensor or You, including from the legal
processes of any jurisdiction or authority.
=======================================================================
Creative Commons is not a party to its public
licenses. Notwithstanding, Creative Commons may elect to apply one of
its public licenses to material it publishes and in those instances
will be considered the “Licensor.” The text of the Creative Commons
public licenses is dedicated to the public domain under the CC0 Public
Domain Dedication. Except for the limited purpose of indicating that
material is shared under a Creative Commons public license or as
otherwise permitted by the Creative Commons policies published at
creativecommons.org/policies, Creative Commons does not authorize the
use of the trademark "Creative Commons" or any other trademark or logo
of Creative Commons without its prior written consent including,
without limitation, in connection with any unauthorized modifications
to any of its public licenses or any other arrangements,
understandings, or agreements concerning use of licensed material. For
the avoidance of doubt, this paragraph does not form part of the
public licenses.
Creative Commons may be contacted at creativecommons.org.

View File

@@ -1,47 +0,0 @@
# 聪明办法学Python
大家好我是小雨姑娘。双非本科自学数据挖掘曾两次获得数据挖掘比赛冠军被选入2020数据挖掘竞赛十大开源贡献者人工智能开源组织Datawhale成员现于北美攻读计算机博士学位。创作本教程的初心是提供一个更快捷有效的 Python 入门途径,让大家在最短时间内补充需要的知识技能,从而更快完成自己的目标。
**学习完本教程你可以收获什么?**
1. 尝试使用Python完成项目解决问题的能力。
2. 对必备Python知识点的掌握。
3. 对经典理论与算法的了解。
**本教程适合哪类同学学习?**
1. 想要从0开始系统学习 Python 的同学。
2. 需要在最短时间内学习 Python 解决当下问题的同学。
3. 对 Python 感兴趣想要了解的同学。
**本教程不适合哪类同学学习?**
1. 希望精进 Python 高阶用法的同学。
2. 希望全面学习掌握 Python 知识点的同学。
*在开发本教程的同时,作者也在构思一套有上述需求同学适合的教程。*
**本教程相对市面其他材料的特点?**
1. 简明。专注 Python 编程的核心能力与技术,不涉及冷门/非必要相关知识。
2. 系统知识体系。从无到有一点点构建知识体系,拒绝琐碎知识点的堆叠。
3. 注重实践。通过代码讲解理论,辅以实例加以巩固。
柏拉图曾经说过:“良好的开端等于成功的一半”。大家选择本教程作为建起万丈高楼的地基,对于我而言便是莫大的荣幸。衷心希望大家在本教程陪伴下迈向未来的同时,也能享受学习过程中带来的乐趣。
## 如何使用这套教程?
1. 在 Github 网页版直接打开 ipynb 文件按顺序查看 (推荐)
2. 本地下载安装 jupyter notebook 运行 ipynb 文件,安装使用方法可参考这篇 [博客](https://www.jianshu.com/p/91365f343585/)
3. 在 [和鲸社区](https://www.heywhale.com) 创建项目,上传 .ipynb 文件可在线运行
4. 在 [Google Colab](https://www.colab.google.com) 上传 .ipynb 在线运行 (需要科学上网)
## 联系方式
知乎 [@小雨姑娘](https://www.zhihu.com/people/xuechuanyu)
Email: chuanyu.xue@uconn.edu
## 关注我们
<div align=center><img src="https://raw.githubusercontent.com/datawhalechina/pumpkin-book/master/res/qrcode.jpeg" width = "250" height = "270" alt="Datawhale是一个专注AI领域的开源组织以“for the learner和学习者一起成长”为愿景构建对学习者最有价值的开源学习社区。关注我们一起学习成长。"></div>
## LICENSE
<a rel="license" href="http://creativecommons.org/licenses/by-nc-sa/4.0/"><img alt="知识共享许可协议" style="border-width:0" src="https://img.shields.io/badge/license-CC%20BY--NC--SA%204.0-lightgrey" /></a><br />本作品采用<a rel="license" href="http://creativecommons.org/licenses/by-nc-sa/4.0/">知识共享署名-非商业性使用-相同方式共享 4.0 国际许可协议</a>进行许可。

View File

@@ -0,0 +1,506 @@
{
"cells": [
{
"cell_type": "markdown",
"id": "68e6c596",
"metadata": {
"slideshow": {
"slide_type": "slide"
}
},
"source": [
"# Chapter 0 安装 Installation"
]
},
{
"cell_type": "markdown",
"id": "e3b9b6a8",
"metadata": {
"slideshow": {
"slide_type": "slide"
}
},
"source": [
"## 安装清单\n",
"- Miniconda: https://docs.conda.io/en/latest/miniconda.html\n",
"- Visual Studio Code: https://code.visualstudio.com/"
]
},
{
"cell_type": "markdown",
"id": "e3eb91af",
"metadata": {
"slideshow": {
"slide_type": "slide"
}
},
"source": [
"## Miniconda 安装配置"
]
},
{
"cell_type": "markdown",
"id": "4585b342",
"metadata": {
"slideshow": {
"slide_type": "subslide"
}
},
"source": [
"### 下载 Miniconda\n",
"\n",
"Miniconda 下载地址:<https://docs.conda.io/en/latest/miniconda.html>\n",
"\n",
"最新版 Miniconda For Windows 下载链接:\n",
"\n",
"<https://repo.anaconda.com/miniconda/Miniconda3-latest-Windows-x86_64.exe>"
]
},
{
"cell_type": "markdown",
"id": "d9358602",
"metadata": {
"cell_style": "center",
"slideshow": {
"slide_type": "subslide"
}
},
"source": [
"### Windows 下安装配置推荐\n",
"\n",
"- Just Me (recommended)\n",
"- Clear the package cache upon completion"
]
},
{
"cell_type": "markdown",
"id": "963b4fd9",
"metadata": {
"cell_style": "split"
},
"source": [
"![](./image/chap0/miniconda_installation_1.png)"
]
},
{
"cell_type": "markdown",
"id": "5d2168a7",
"metadata": {
"cell_style": "split"
},
"source": [
"![](./image/chap0/miniconda_installation_2.png)"
]
},
{
"cell_type": "markdown",
"id": "0312d547",
"metadata": {
"slideshow": {
"slide_type": "subslide"
}
},
"source": [
"## 修改 Powershell 执行策略(可选)\n",
"\n",
"在`开始`图标**右键单击**,选择 `Windows PowerShell管理员`\n",
"\n",
"先输入下面的内容,并回车:\n",
"```powershell\n",
"Set-ExecutionPolicy -Scope CurrentUser RemoteSigned\n",
"```\n",
"出现如下内容后,输入:`A`,回车:\n",
"\n",
"![](../resources/slides/chap0/pic/powershell.png)\n",
"\n",
"最后在 **Anaconda Powershell Prompt** 中输入:\n",
"```bash\n",
"conda init\n",
"```"
]
},
{
"cell_type": "markdown",
"id": "50b897f3",
"metadata": {
"slideshow": {
"slide_type": "slide"
}
},
"source": [
"## 更换镜像源\n",
"\n",
"- Pip 换源\n",
"- Conda 换源\n",
"\n",
"> 加快国内资源下载速度"
]
},
{
"cell_type": "markdown",
"id": "5ec52c36",
"metadata": {
"cell_style": "center",
"slideshow": {
"slide_type": "subslide"
}
},
"source": [
"### 校园网联合镜像站\n",
"<https://help.mirrors.cernet.edu.cn/>\n",
"\n",
"### 阿里巴巴开源镜像站\n",
"\n",
"<https://developer.aliyun.com/mirror/>\n",
"\n",
"请避免使用代理,不合理的代理设置会导致下载失败"
]
},
{
"cell_type": "markdown",
"id": "02919362",
"metadata": {
"slideshow": {
"slide_type": "subslide"
}
},
"source": [
"### Conda 更换镜像源\n",
"\n",
"清华大学开源软件镜像站:<https://help.mirrors.cernet.edu.cn/anaconda/>\n",
"\n",
"南方科技大学开源软件镜像站:<https://help.mirrors.cernet.edu.cn/anaconda-extra/>\n",
"\n",
"在 **Anaconda Powershell Prompt** 中输入:\n",
"\n",
"```bash\n",
"conda config --set show_channel_urls yes\n",
"```\n",
"\n",
"在镜像站复制文本后,在 **Anaconda Powershell Prompt** 中输入:\n",
"\n",
"```bash\n",
"notepad .condarc # 注意有个小点 \".\" 在 \"condarc\" 的前面\n",
"```\n",
"\n",
"粘贴刚刚复制的文本,保存文件后关闭\n",
"\n",
"最后在 **Anaconda Powershell Prompt** 中输入:\n",
"\n",
"```bash\n",
"conda clean -i # 清除源缓存,以启用镜像源\n",
"```"
]
},
{
"cell_type": "markdown",
"id": "0de0a2be",
"metadata": {
"slideshow": {
"slide_type": "subslide"
}
},
"source": [
"## PyPI 更换镜像源\n",
" \n",
"校园网联合镜像站:<https://help.mirrors.cernet.edu.cn/pypi/>\n",
"\n",
"复制文本后,在 **Anaconda Powershell Prompt** 中粘贴运行即可:\n",
"\n",
"```bash\n",
"# 设置 PyPI 镜像源\n",
"pip config set global.index-url https://mirrors.cernet.edu.cn/pypi/web/simple \n",
"```"
]
},
{
"cell_type": "markdown",
"id": "054f6cbc",
"metadata": {
"slideshow": {
"slide_type": "slide"
}
},
"source": [
"## 课程环境搭建"
]
},
{
"cell_type": "markdown",
"id": "d8028b9c",
"metadata": {
"slideshow": {
"slide_type": "subslide"
}
},
"source": [
"### 创建与激活 Conda 环境\n",
"\n",
"创建 Conda 环境\n",
"\n",
"```bash\n",
"conda create -n Datawhale python=3.10 # conda 环境创建\n",
"```\n",
"\n",
"其中 ***-n*** 代表创建的环境名称,这里是 ***Datawhale***,并指定 ***Python 版本为 3.10***\n",
"\n",
"激活刚刚创建的 Conda 环境:\n",
"\n",
"```bash\n",
"conda activate Datawhale # 激活 Datawhale 环境,不同环境的 Python 包版本不同!\n",
"```\n",
"\n",
"如果需要删除某个 Conda 环境:\n",
"\n",
"```bash\n",
"conda deactivate # 退出该环境\n",
"conda remove -n Datawhale --all # 删除整个环境\n",
"```"
]
},
{
"cell_type": "markdown",
"id": "4cac85fe",
"metadata": {
"cell_style": "split",
"slideshow": {
"slide_type": "subslide"
}
},
"source": [
"## Pip 安装与展示\n",
"\n",
"Pip 安装课程所需第三方库\n",
"\n",
"```bash\n",
"pip install jupyter\n",
"```\n",
"\n",
"在指定路径输入:\n",
"\n",
"```bash\n",
"jupyter-notebook # 会自动跳转到浏览器\n",
"```\n",
"\n",
"结束学习时使用:\n",
"\n",
"```bash\n",
"Ctrl + C # 关闭 Jupyter Notebook 服务\n",
"```"
]
},
{
"cell_type": "markdown",
"id": "708d553e",
"metadata": {
"cell_style": "split",
"slideshow": {
"slide_type": "fragment"
}
},
"source": [
"### 安装清单\n",
"\n",
"数据挖掘:\n",
"- scikit-learn\n",
"- numpy\n",
"- pandas\n",
"- tqdm\n",
"- lightgbm (数据挖掘模型)\n",
"\n",
"CV\n",
"- nibabel\n",
"- pillow"
]
},
{
"cell_type": "markdown",
"id": "8aedd2d4",
"metadata": {
"slideshow": {
"slide_type": "subslide"
}
},
"source": [
"### Conda 安装与展示\n",
"\n",
"首先在 **Anaconda Powershell Prompt** 中输入:\n",
"\n",
"```bash\n",
"nvidia-smi # 查看当前 GPU 支持的最高 CUDA 版本\n",
"```\n",
"\n",
"![](../resources/slides/chap0/pic/CUDA_info.png)\n",
"\n",
"**Pytorch** 安装: <https://pytorch.org/get-started/locally/>\n",
"\n",
"```bash\n",
"conda install pytorch torchvision torchaudio pytorch-cuda=11.8 -c pytorch -c nvidia\n",
"```\n",
"\n",
"**PaddlePaddle** 安装:<https://www.paddlepaddle.org.cn>\n",
"```bash\n",
"conda install paddlepaddle-gpu==2.4.2 cudatoolkit=11.7 -c Paddle -c conda-forge\n",
"```"
]
},
{
"cell_type": "markdown",
"id": "109adde7",
"metadata": {
"slideshow": {
"slide_type": "subslide"
}
},
"source": [
"## CUDA 验证"
]
},
{
"cell_type": "markdown",
"id": "5651891e",
"metadata": {},
"source": [
"在 **Anaconda Powershell Prompt** 中输入:\n",
"\n",
"```bash\n",
"ipython # 交互 Python 运行环境\n",
"```\n",
"\n",
"使用 `exit` 或 `exit()` 来退出 **IPython**"
]
},
{
"cell_type": "markdown",
"id": "f6021cd5",
"metadata": {
"cell_style": "split",
"slideshow": {
"slide_type": "fragment"
}
},
"source": [
"PaddlePaddle:\n",
"\n",
"```python\n",
">>> import paddle\n",
">>> paddle.utils.run_check()\n",
"```\n",
"\n",
"正确输出:\n",
"```plain\n",
"PaddlePaddle works well on 1 GPU.\n",
"PaddlePaddle is installed successfully! Let's start deep learning with PaddlePaddle now.\n",
"```"
]
},
{
"cell_type": "markdown",
"id": "de874521",
"metadata": {
"cell_style": "split",
"slideshow": {
"slide_type": "fragment"
}
},
"source": [
"Pytorch:\n",
"\n",
"```python\n",
">>> import torch\n",
">>> torch.cuda.is_available()\n",
"```\n",
"\n",
"正常输出:\n",
"\n",
"```python\n",
"True\n",
"```"
]
},
{
"cell_type": "markdown",
"id": "0d011cdf",
"metadata": {
"slideshow": {
"slide_type": "slide"
}
},
"source": [
"## 云端环境的使用\n",
"- 百度飞桨 AI Studio https://aistudio.baidu.com/aistudio/index\n",
"- 阿里天池 PAI DSW https://tianchi.aliyun.com/notebook-ai\n",
"- Kaggle https://www.kaggle.com/code\n",
"- Google Colab https://colab.research.google.com/\n",
"- Sagemaker Studio Lab https://studiolab.sagemaker.aws/"
]
}
],
"metadata": {
"celltoolbar": "Slideshow",
"kernelspec": {
"display_name": "Python 3 (ipykernel)",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.11.5"
},
"rise": {
"overlay": "<div class='my-top-right'><img height=40px src='../resources/datawhale_logo.png'/></div><div class='my-top-left'></div>"
},
"toc": {
"base_numbering": 1,
"nav_menu": {},
"number_sections": true,
"sideBar": true,
"skip_h1_title": false,
"title_cell": "Table of Contents",
"title_sidebar": "Contents",
"toc_cell": false,
"toc_position": {},
"toc_section_display": true,
"toc_window_display": false
},
"varInspector": {
"cols": {
"lenName": 16,
"lenType": 16,
"lenVar": 40
},
"kernels_config": {
"python": {
"delete_cmd_postfix": "",
"delete_cmd_prefix": "del ",
"library": "var_list.py",
"varRefreshCmd": "print(var_dic_list())"
},
"r": {
"delete_cmd_postfix": ") ",
"delete_cmd_prefix": "rm(",
"library": "var_list.r",
"varRefreshCmd": "cat(var_dic_list()) "
}
},
"types_to_exclude": [
"module",
"function",
"builtin_function_or_method",
"instance",
"_Feature"
],
"window_display": false
}
},
"nbformat": 4,
"nbformat_minor": 5
}

File diff suppressed because it is too large Load Diff

33
notebook/conf.py Normal file
View File

@@ -0,0 +1,33 @@
extensions = [
"myst_nb",
'sphinx_copybutton', # sphinx-copybutton.readthedocs.io
'sphinx_design', # github.com/executablebooks/sphinx-design
'sphinx_togglebutton', # sphinx-togglebutton.readthedocs.io
"sphinx.ext.githubpages",
]
myst_enable_extensions = ['colon_fence', 'deflist', 'dollarmath', 'html_image', 'substitution']
master_doc = "index"
project = "聪明办法学 Python"
copyright = "2022 - 2024 Datawhale P2S Team"
author = "P2S Team"
exclude_patterns = ["_build", "Thumbs.db", ".DS_Store", "**.ipynb_checkpoints"]
nitpicky = True
language = "zh_CN"
html_theme = "furo"
html_title = "<div align=center><small>聪明办法学 Python</small></div>"
html_logo = "./image/datawhale_logo.png"
html_theme_options = {
"announcement": "聪明办法学 Python 在线文档 Beta 测试",
"source_repository": "https://github.com/anine09/p2s-book",
"source_branch": "main",
"source_directory": "docs/",
}
nb_number_source_lines = True
nb_execution_mode = 'off'
nb_execution_in_temp = True

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 74 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 164 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 83 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 202 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 145 KiB

View File

@@ -0,0 +1,4 @@
1. AI Master —— 李宏毅 机器学习
![](chap1_1_AIMaster.jpg)
2. [Brian Kernighan](https://en.wikipedia.org/wiki/Brian_Kernighan#/media/File:Brian-Kernighan-2017.png)
![](chap1_1_464px-Brian-Kernighan-2017.png)

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 64 KiB

74
notebook/index.md Normal file
View File

@@ -0,0 +1,74 @@
---
sd_hide_title: true
---
# sphinx-design
::::::{div} landing-title
:style: "padding: 0.1rem 0.5rem 0.6rem 0; background-image: linear-gradient(315deg, #438ff9 0%, #1572f4 74%); clip-path: polygon(0px 0px, 100% 0%, 100% 100%, 0% calc(100% - 1.5rem)); -webkit-clip-path: polygon(0px 0px, 100% 0%, 100% 100%, 0% calc(100% - 1.5rem));"
::::{grid}
:reverse:
:gutter: 2 3 3 3
:margin: 4 4 1 2
:::{grid-item}
:columns: 12 4 4 4
```{image} ./image/white_datawhale_logo.png
:width: 300px
:class: sd-m-auto sd-animate-grow50-rot20
```
:::
:::{grid-item}
:columns: 12 8 8 8
:child-align: justify
:class: sd-text-white sd-fs-3
简明且系统的 Python 入门教程
```{button-link} https://datawhalechina.github.io/learn-python-the-smart-way-v2/
:ref-type: doc
:outline:
:color: white
:class: sd-px-4 sd-fs-5
课程主页
```
:::
::::
::::::
:::::{tab-set}
::::{tab-item} 基础部分
:::{dropdown} Chapter 0 安装 Installation
:animate: fade-in-slide-down
:color: primary
```{toctree}
:maxdepth: 2
:caption: 目录
chapter_0-Installation.ipynb
```
:::
:::{dropdown} Chapter 1 启航 Getting Started
:animate: fade-in-slide-down
:color: primary
<p>目录</p>
```{toctree}
:maxdepth: 2
chapter_1-Getting_Started.ipynb
```
:::
::::
::::{tab-item} 进阶部分
筹划中,敬请期待。
::::
:::::

BIN
requirements.txt Normal file

Binary file not shown.

Binary file not shown.

Before

Width:  |  Height:  |  Size: 392 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 491 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 418 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 719 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 415 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 273 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 278 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 342 KiB