提交 9db8c1b2 编写于 作者: 写代码的明哥's avatar 写代码的明哥

update

上级 524dc30a
此差异已折叠。
......@@ -41,7 +41,7 @@ def get_toc_info():
section = int(re.findall(r"c\d{2}_(\d{2}).md", file_name)[0])
#md_path = os.path.join("./source/", dir_name, file_name)
md_path = os.path.join("http://demo.iswbm.com/en/latest/", dir_name, file_name.replace("md", "html"))
md_path = os.path.join("http://python.iswbm.com/en/latest/", dir_name, file_name.replace("md", "html"))
title = get_title(file)
if not title:
continue
......
......@@ -15,7 +15,7 @@ elif (osName == 'Darwin'):
blog_path = '/Users/MING/Github/python-guide/source'
index_path = '/Users/MING/Github/python-guide/README.md'
base_link = "http://demo.iswbm.com/en/latest/"
base_link = "http://python.iswbm.com/en/latest/"
readme_header = '''
![](http://image.iswbm.com/20200607120940.png)
......@@ -27,9 +27,9 @@ readme_header = '''
<a href='http://image.iswbm.com/20200607114246.png'><img src='http://img.shields.io/badge/%E5%85%AC%E4%BC%97%E5%8F%B7-30k+-brightgreen'></a>
</p>
## [项目主页](http://demo.iswbm.com/)
## [项目主页](http://python.iswbm.com/)
在线阅读:[Python 编程时光](http://demo.iswbm.com/)
在线阅读:[Python 编程时光](http://python.iswbm.com/)
![](http://image.iswbm.com/20200607130051.png)
......
......@@ -93,24 +93,13 @@ b。类似这样的控制流程语句,称之为条件语句。
在讲多个条件组合时,先来了解一下 Python 中的逻辑运算符。
以下假设变量 a 为 10, b为 20:
+---+------+------------------------------------------+---------------+
| 运 | 逻辑表达 | 描述 | 实例 |
| 算 | 式 | | |
| 符 | | | |
+===+======+==========================================+===============+
| a | x | 布尔“与” - 如果 x 为 False,x and y 返回 | (a and b) |
| n | and | False,否则它返回 y 的计算值。 | 返回 20。 |
| d | y | | |
+---+------+------------------------------------------+---------------+
| o | x or | 布尔“或” - 如果 x 是非 0,它返回 x | (a or b) 返回 |
| r | y | 的值,否则它返回 y 的计算值。 | 10。 |
+---+------+------------------------------------------+---------------+
| n | not | 布尔“非” - 如果 x 为 True,返回 False | not(a and b) |
| o | x | 。如果 x 为 False,它返回 True。 | 返回 False |
| t | | | |
+---+------+------------------------------------------+---------------+
以下假设变量 a 为 10, b为 20: \| 运算符 \| 逻辑表达式 \| 描述\| 实例 \|
\| — \| — \| — \| — \| \| and \| x and y \| 布尔“与” - 如果 x 为
False,x and y 返回 False,否则它返回 y 的计算值。 \| (a and b) 返回
20。 \| \| or \| x or y \| 布尔“或” - 如果 x 是非 0,它返回 x
的值,否则它返回 y 的计算值。 \| (a or b) 返回 10。 \| \| not \| not x
\| 布尔“非” - 如果 x 为 True,返回 False 。如果 x 为 False,它返回
True。 \| not(a and b) 返回 False \|
学习完逻辑运算符,就可以开始写多条件语句
......
......@@ -124,7 +124,7 @@ def fact(n):
def demo_func():
return 1,2.3
```
- 可以是其他函数,利用这点可以实现装饰器。这部分属于进阶内容,感兴趣可查看另一章节内容:[5.6 精通装饰器的八种用法](https://demo.iswbm.com/en/latest/c05/c05_06.html)
- 可以是其他函数,利用这点可以实现装饰器。这部分属于进阶内容,感兴趣可查看另一章节内容:[5.6 精通装饰器的八种用法](https://python.iswbm.com/en/latest/c05/c05_06.html)
```python
def decorator(func):
def wrapper(*args, **kw):
......
......@@ -137,7 +137,7 @@
return 1,2.3
- 可以是其他函数,利用这点可以实现装饰器。这部分属于进阶内容,感兴趣可查看另一章节内容:\ `5.6
精通装饰器的八种用法 <https://demo.iswbm.com/en/latest/c05/c05_06.html>`__
精通装饰器的八种用法 <https://python.iswbm.com/en/latest/c05/c05_06.html>`__
.. code:: python
......
......@@ -39,7 +39,7 @@ with EXPR as VAR:
## 2. 如何写上下文管理器?
要手动实现一个上下文管理器,需要你有对类有一些了解,至少需要知道什么是类,怎么定义类。对于类的知识,我放在了第七章,因此你可以先前往学习下第七章的的第一节内容:[7.1 类的理解与使用](https://demo.iswbm.com/en/latest/c07/c07_01.html)
要手动实现一个上下文管理器,需要你有对类有一些了解,至少需要知道什么是类,怎么定义类。对于类的知识,我放在了第七章,因此你可以先前往学习下第七章的的第一节内容:[7.1 类的理解与使用](https://python.iswbm.com/en/latest/c07/c07_01.html)
学习了类的基本知识,想要自己实现这样一个上下文管理,就简单了。
......
......@@ -45,7 +45,7 @@
-----------------------
要手动实现一个上下文管理器,需要你有对类有一些了解,至少需要知道什么是类,怎么定义类。对于类的知识,我放在了第七章,因此你可以先前往学习下第七章的的第一节内容:\ `7.1
类的理解与使用 <https://demo.iswbm.com/en/latest/c07/c07_01.html>`__ 。
类的理解与使用 <https://python.iswbm.com/en/latest/c07/c07_01.html>`__ 。
学习了类的基本知识,想要自己实现这样一个上下文管理,就简单了。
......
......@@ -4,8 +4,8 @@
自定义异常,需要你对 `类``继承` 有一些了解,对于类的知识,我放在了第七章,因此你可以先前往学习下第七章的的下面两节内容:
- [7.1 类的理解与使用](https://demo.iswbm.com/en/latest/c07/c07_01.html)
- [7.5 类的继承(Inheritance)](https://demo.iswbm.com/en/latest/c07/c07_05.html)
- [7.1 类的理解与使用](https://python.iswbm.com/en/latest/c07/c07_01.html)
- [7.5 类的继承(Inheritance)](https://python.iswbm.com/en/latest/c07/c07_05.html)
等学习完后再回过头来学习本节内容。
......
......@@ -7,9 +7,9 @@
有一些了解,对于类的知识,我放在了第七章,因此你可以先前往学习下第七章的的下面两节内容:
- `7.1
类的理解与使用 <https://demo.iswbm.com/en/latest/c07/c07_01.html>`__
类的理解与使用 <https://python.iswbm.com/en/latest/c07/c07_01.html>`__
- `7.5
类的继承(Inheritance) <https://demo.iswbm.com/en/latest/c07/c07_05.html>`__
类的继承(Inheritance) <https://python.iswbm.com/en/latest/c07/c07_05.html>`__
等学习完后再回过头来学习本节内容。
......
......@@ -38,7 +38,7 @@
.. code:: python
try:
print(1 / 0)
print(1/0)
except Exception as exc:
raise RuntimeError("Something bad happened") from exc
......
......@@ -40,7 +40,7 @@ $ pip install pkg>=2.1.2
$ pip install pkg<=2.1.2
```
更多 pip 的使用方法,可参考本系列教程后面的文章,介绍得非常清楚:[8.8 pip 的详细使用指南](https://demo.iswbm.com/en/latest/c08/c08_08.html)
更多 pip 的使用方法,可参考本系列教程后面的文章,介绍得非常清楚:[8.8 pip 的详细使用指南](https://python.iswbm.com/en/latest/c08/c08_08.html)
## 3. 使用 pipx
......@@ -61,7 +61,7 @@ Success!
$ pipx install pkg
```
更多 pipx 的使用方法,可参考本系列教程后面的文章,介绍得非常清楚:[12.4 pipx 安装程序的使用指南](https://demo.iswbm.com/en/latest/c12/c12_04.html)
更多 pipx 的使用方法,可参考本系列教程后面的文章,介绍得非常清楚:[12.4 pipx 安装程序的使用指南](https://python.iswbm.com/en/latest/c12/c12_04.html)
## 4. 使用 setup.py
......@@ -74,7 +74,7 @@ $ python setup.py install
## 5. 使用 yum
Python 包在使用 `setup.py` 构建的时候(具体内容可阅读后面的内容:[8.15 超详细讲解 setup.py 的编写](https://demo.iswbm.com/en/latest/c08/c08_15.html)),对于包的发布格式有多种选项,其中有一个选项是 `bdist_rpm`,以这个选项发布出来的包是 `rpm` 的包格式。
Python 包在使用 `setup.py` 构建的时候(具体内容可阅读后面的内容:[8.15 超详细讲解 setup.py 的编写](https://python.iswbm.com/en/latest/c08/c08_15.html)),对于包的发布格式有多种选项,其中有一个选项是 `bdist_rpm`,以这个选项发布出来的包是 `rpm` 的包格式。
```shell
# 发布 rpm 包
......
8.2 【基础】安装第三方包的种方法
8.2 【基础】安装第三方包的种方法
==================================
1. 使用 easy_install
......@@ -47,7 +47,7 @@ pip 是最主流的包管理方案,使用 ``pip install xxx`` 就可以从 PYP
$ pip install pkg<=2.1.2
更多 pip 的使用方法,可参考本系列教程后面的文章,介绍得非常清楚:\ `8.8
pip 的详细使用指南 <https://demo.iswbm.com/en/latest/c08/c08_08.html>`__
pip 的详细使用指南 <https://python.iswbm.com/en/latest/c08/c08_08.html>`__
3. 使用 pipx
------------
......@@ -67,22 +67,34 @@ pipx 是一个专门用于安装和管理 cli 应用程序的工具,使用它
.. code:: shell
# 创建虚拟环境并安装包
$ pipx install pkg
更多 pipx
的使用方法,可参考本系列教程后面的文章,介绍得非常清楚:\ `12.4 pipx
安装程序的使用指南 <https://demo.iswbm.com/en/latest/c12/c12_04.html>`__
安装程序的使用指南 <https://python.iswbm.com/en/latest/c12/c12_04.html>`__
4. 使用 yum install
-------------------
4. 使用 setup.py
----------------
如果你有编写 setup.py 文件,可以使用如下命令直接安装
.. code:: python
# 使用源码直接安装
$ python setup.py install
5. 使用 yum
-----------
Python 包在使用 ``setup.py``
构建的时候(具体内容可阅读后面的内容:\ `8.15 超详细讲解 setup.py
的编写 <https://demo.iswbm.com/en/latest/c08/c08_15.html>`__\ ),对于包的发布格式有多种选项,其中有一个选项是
的编写 <https://python.iswbm.com/en/latest/c08/c08_15.html>`__\ ),对于包的发布格式有多种选项,其中有一个选项是
``bdist_rpm``\ ,以这个选项发布出来的包是 ``rpm`` 的包格式。
.. code:: shell
# 发布 rpm 包
$ python setup.py bdist_rpm
对于\ ``rpm`` 这种格式,你需要使用 ``yum install xxx`` 或者
......@@ -90,5 +102,41 @@ Python 包在使用 ``setup.py``
.. code:: shell
# 使用 yum 安装
$ yum install pkg
$ rpm install pkg
# 使用 rpm 安装
$ rpm -ivh pkg
6. 使用 pipenv
--------------
如果你在使用 pipenv
创建的虚拟环境中,可以使用下面这条命令把包安装到虚拟环境中
.. code:: shell
$ pipenv install pkg
7. 使用 poetry
--------------
如果你有使用 poetry 管理项目依赖,那么可以使用下面这条命令安装包
.. code:: shell
# 直接安装包
$ poetry add pkg
# 指定为开发依赖
$ poetry add pytest --dev
8. 使用 curl + 管道
-------------------
有一些第三方工具包提供的安装方法,是直接使用 curl
配置管道来安装,比如上面提到的 poetry 就可以用这种方法安装。
.. code:: shell
$ curl -sSL https://raw.githubusercontent.com/python-poetry/poetry/master/get-poetry.py | python
......@@ -11,9 +11,8 @@
.. code:: python
# profile.py
name='wangbm'
age=27
gender='male'
name='小明'
age=18
__all__=['name']
......@@ -23,15 +22,11 @@
>>> from profile import *
>>> print(name)
wangbm
小明
>>> print(age)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
NameError: name 'age' is not defined
>>> print(gender)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
NameError: name 'gender' is not defined
``__all__`` 仅对于使用\ ``from module import *`` 这种情况适用。
......
......@@ -22,7 +22,7 @@
$ brew install pipenv
# windows
pip install [--user] pipenv
$ pip install [--user] pipenv
如果你的电脑是 windows 的。
......
- **第一章:安装运行**
* [1.1 安装 Python 解释器](http://demo.iswbm.com/en/latest/c01/c01_01.html)
* [1.2 第一个 Python 程序](http://demo.iswbm.com/en/latest/c01/c01_02.html)
* [1.3 Python 开发环境的搭建](http://demo.iswbm.com/en/latest/c01/c01_03.html)
* [1.4 运行 Python 脚本的两种方法](http://demo.iswbm.com/en/latest/c01/c01_04.html)
- **第二章:数据类型**
* [2.1 常量与变量](http://demo.iswbm.com/en/latest/c02/c02_01.html)
* [2.2 字符串类型](http://demo.iswbm.com/en/latest/c02/c02_02.html)
* [2.3 整型与浮点数](http://demo.iswbm.com/en/latest/c02/c02_03.html)
* [2.4 布尔值:真与假](http://demo.iswbm.com/en/latest/c02/c02_04.html)
* [2.5 输入与输出](http://demo.iswbm.com/en/latest/c02/c02_05.html)
* [2.6 运算符](http://demo.iswbm.com/en/latest/c02/c02_06.html)
- **第三章:数据结构**
* [3.1 列表](http://demo.iswbm.com/en/latest/c03/c03_01.html)
* [3.2 元组](http://demo.iswbm.com/en/latest/c03/c03_02.html)
* [3.3 字典](http://demo.iswbm.com/en/latest/c03/c03_03.html)
* [3.4 集合](http://demo.iswbm.com/en/latest/c03/c03_04.html)
* [3.5 迭代器](http://demo.iswbm.com/en/latest/c03/c03_05.html)
* [3.6 生成器](http://demo.iswbm.com/en/latest/c03/c03_06.html)
- **第四章:控制流程**
* [4.1 条件语句:if](http://demo.iswbm.com/en/latest/c04/c04_01.html)
* [4.2 循环语句:for](http://demo.iswbm.com/en/latest/c04/c04_02.html)
* [4.3 循环语句:while](http://demo.iswbm.com/en/latest/c04/c04_03.html)
* [4.4 五种推导式](http://demo.iswbm.com/en/latest/c04/c04_04.html)
- **第五章:学习函数**
* [5.1 普通函数](http://demo.iswbm.com/en/latest/c05/c05_01.html)
* [5.2 匿名函数](http://demo.iswbm.com/en/latest/c05/c05_02.html)
* [5.3 高阶函数](http://demo.iswbm.com/en/latest/c05/c05_03.html)
* [5.4 反射函数](http://demo.iswbm.com/en/latest/c05/c05_04.html)
* [5.5 偏函数](http://demo.iswbm.com/en/latest/c05/c05_05.html)
* [5.6 泛型函数](http://demo.iswbm.com/en/latest/c05/c05_06.html)
* [5.7 with 与上下文管理器](http://demo.iswbm.com/en/latest/c05/c05_07.html)
* [5.8 装饰器的八种写法](http://demo.iswbm.com/en/latest/c05/c05_08.html)
* [5.9 变量的作用域](http://demo.iswbm.com/en/latest/c05/c05_09.html)
- **第六章:错误异常**
* [6.1 什么是异常?](http://demo.iswbm.com/en/latest/c06/c06_01.html)
* [6.2 如何捕获异常](http://demo.iswbm.com/en/latest/c06/c06_02.html)
* [6.3 如何自定义异常](http://demo.iswbm.com/en/latest/c06/c06_03.html)
* [6.4 异常处理的三个好习惯](http://demo.iswbm.com/en/latest/c06/c06_04.html)
- **第七章:类与对象**
* [7.1 类的理解与使用](http://demo.iswbm.com/en/latest/c07/c07_01.html)
* [7.2 静态方法与类方法](http://demo.iswbm.com/en/latest/c07/c07_02.html)
* [7.3 私有变量与私有方法](http://demo.iswbm.com/en/latest/c07/c07_03.html)
* [7.4 类的封装(Encapsulation)](http://demo.iswbm.com/en/latest/c07/c07_04.html)
* [7.5 类的继承(Inheritance)](http://demo.iswbm.com/en/latest/c07/c07_05.html)
* [7.6 类的多态(Polymorphism)](http://demo.iswbm.com/en/latest/c07/c07_06.html)
* [7.7 类的 property 属性](http://demo.iswbm.com/en/latest/c07/c07_07.html)
* [7.8 类的 Mixin 设计模式](http://demo.iswbm.com/en/latest/c07/c07_08.html)
* [7.9 深入理解描述符](http://demo.iswbm.com/en/latest/c07/c07_09.html)
* [7.10 学习元类编程](http://demo.iswbm.com/en/latest/c07/c07_10.html)
- **第八章:包与模块**
* [8.1 什么是包、模块和库?](http://demo.iswbm.com/en/latest/c08/c08_01.html)
* [8.2 安装第三方包的四种方法](http://demo.iswbm.com/en/latest/c08/c08_02.html)
* [8.3 导入单元的构成](http://demo.iswbm.com/en/latest/c08/c08_03.html)
* [8.4 导入包的标准写法](http://demo.iswbm.com/en/latest/c08/c08_04.html)
* [8.5 什么是空间命名包?](http://demo.iswbm.com/en/latest/c08/c08_05.html)
* [8.6 花式导包的八种方法](http://demo.iswbm.com/en/latest/c08/c08_06.html)
* [8.7 包导入的三个冷门知识点](http://demo.iswbm.com/en/latest/c08/c08_07.html)
* [8.8 pip 的详细使用指南](http://demo.iswbm.com/en/latest/c08/c08_08.html)
* [8.9 理解模块的缓存](http://demo.iswbm.com/en/latest/c08/c08_09.html)
* [8.10 理解查找器与加载器](http://demo.iswbm.com/en/latest/c08/c08_10.html)
* [8.11 实现远程导入模块](http://demo.iswbm.com/en/latest/c08/c08_11.html)
* [8.12 分发工具:distutils和setuptools](http://demo.iswbm.com/en/latest/c08/c08_12.html)
* [8.13 源码包与二进制包有什么区别?](http://demo.iswbm.com/en/latest/c08/c08_13.html)
* [8.14 eggs与wheels 有什么区别?](http://demo.iswbm.com/en/latest/c08/c08_14.html)
* [8.15 超详细讲解 setup.py 的编写](http://demo.iswbm.com/en/latest/c08/c08_15.html)
* [8.16 打包辅助神器 PBR 是什么?](http://demo.iswbm.com/en/latest/c08/c08_16.html)
* [8.17 开源自己的包到 PYPI 上](http://demo.iswbm.com/en/latest/c08/c08_17.html)
- **第九章:调试技巧**
* [9.1 超详细图文教你调试代码](http://demo.iswbm.com/en/latest/c09/c09_01.html)
* [9.2 PyCharm 中指定参数调试程序](http://demo.iswbm.com/en/latest/c09/c09_02.html)
* [9.3 PyCharm跑完后立即进入调试模式](http://demo.iswbm.com/en/latest/c09/c09_03.html)
* [9.4 脚本报错后立即进入调试模式](http://demo.iswbm.com/en/latest/c09/c09_04.html)
* [9.5 使用 PDB 进行无界面调试](http://demo.iswbm.com/en/latest/c09/c09_05.html)
* [9.6 如何调试已经运行的程序?](http://demo.iswbm.com/en/latest/c09/c09_06.html)
* [9.7 使用 PySnopper 调试疑难杂症](http://demo.iswbm.com/en/latest/c09/c09_07.html)
* [9.8 使用 PyCharm 进行远程调试](http://demo.iswbm.com/en/latest/c09/c09_08.html)
- **第十章:并发编程**
* [10.1 从性能角度初探并发编程](http://demo.iswbm.com/en/latest/c10/c10_01.html)
* [10.2 创建多线程的几种方法](http://demo.iswbm.com/en/latest/c10/c10_02.html)
* [10.3 谈谈线程中的“锁机制”](http://demo.iswbm.com/en/latest/c10/c10_03.html)
* [10.4 线程消息通信机制](http://demo.iswbm.com/en/latest/c10/c10_04.html)
* [10.5 线程中的信息隔离](http://demo.iswbm.com/en/latest/c10/c10_05.html)
* [10.6 线程池创建的几种方法](http://demo.iswbm.com/en/latest/c10/c10_06.html)
* [10.7 从 yield 开始入门协程](http://demo.iswbm.com/en/latest/c10/c10_07.html)
* [10.8 深入理解yield from语法](http://demo.iswbm.com/en/latest/c10/c10_08.html)
* [10.9 初识异步IO框架:asyncio 上篇](http://demo.iswbm.com/en/latest/c10/c10_09.html)
* [10.10 深入异步IO框架:asyncio 中篇](http://demo.iswbm.com/en/latest/c10/c10_10.html)
* [10.11 实战异步IO框架:asyncio 下篇](http://demo.iswbm.com/en/latest/c10/c10_11.html)
* [10.12 生成器与协程,你分清了吗?](http://demo.iswbm.com/en/latest/c10/c10_12.html)
* [10.14 浅谈线程安全那些事儿](http://demo.iswbm.com/en/latest/c10/c10_13.html)
- **第十一章:代码美化**
* [11.1 如何更好进行变量的命名?](http://demo.iswbm.com/en/latest/c11/c11_01.html)
* [11.2 写好函数的 6 个建议](http://demo.iswbm.com/en/latest/c11/c11_02.html)
* [11.3 自觉遵守 PEP8 代码风格](http://demo.iswbm.com/en/latest/c11/c11_03.html)
* [11.4 Pythonic 代码的 15 个案例](http://demo.iswbm.com/en/latest/c11/c11_04.html)
* [11.5 写出漂亮 Python 代码的 20条准则](http://demo.iswbm.com/en/latest/c11/c11_05.html)
- **第十二章:虚拟环境**
* [12.1 为什么要有虚拟环境?](http://demo.iswbm.com/en/latest/c12/c12_01.html)
* [12.2 方案一:virtualenv](http://demo.iswbm.com/en/latest/c12/c12_02.html)
* [12.3 方案二:pipenv](http://demo.iswbm.com/en/latest/c12/c12_03.html)
* [12.4 方案三:使用 pipx](http://demo.iswbm.com/en/latest/c12/c12_04.html)
* [12.5 方案四:使用 poetry](http://demo.iswbm.com/en/latest/c12/c12_05.html)
- **第十三章:工程项目**
* [13.1 使用 flake8 保证代码风格](http://demo.iswbm.com/en/latest/c13/c13_01.html)
* [13.2 使用 mypy 进行静态类型检查](http://demo.iswbm.com/en/latest/c13/c13_02.html)
* [13.3 用 pytest 进行代码测试](http://demo.iswbm.com/en/latest/c13/c13_03.html)
* [13.4 使用 pre-commit hook 解决编码规范](http://demo.iswbm.com/en/latest/c13/c13_04.html)
* [13.5 使用 cookiecutter 生成项目](http://demo.iswbm.com/en/latest/c13/c13_05.html)
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册