Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
后端镜像
Python Guide
提交
524dc30a
P
Python Guide
项目概览
后端镜像
/
Python Guide
通知
0
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
Python Guide
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
524dc30a
编写于
12月 23, 2020
作者:
写代码的明哥
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
update
上级
615688f4
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
54 addition
and
17 deletion
+54
-17
source/c04/c04_01.md
source/c04/c04_01.md
+4
-4
source/c06/c06_04.md
source/c06/c06_04.md
+1
-1
source/c08/c08_02.md
source/c08/c08_02.md
+45
-3
source/c08/c08_07.md
source/c08/c08_07.md
+3
-8
source/c12/c12_03.md
source/c12/c12_03.md
+1
-1
未找到文件。
source/c04/c04_01.md
浏览文件 @
524dc30a
...
...
@@ -84,9 +84,8 @@ ok
在讲多个条件组合时,先来了解一下 Python 中的逻辑运算符。
以下假设变量 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 |
...
...
@@ -111,4 +110,5 @@ if 条件A or 条件B:
# 要求不满足条件A
if
not
条件A
:
...
```
\ No newline at end of file
```
source/c06/c06_04.md
浏览文件 @
524dc30a
...
...
@@ -33,7 +33,7 @@ RuntimeError: Something bad happened
```
python
try
:
print
(
1
/
0
)
print
(
1
/
0
)
except
Exception
as
exc
:
raise
RuntimeError
(
"Something bad happened"
)
from
exc
```
...
...
source/c08/c08_02.md
浏览文件 @
524dc30a
# 8.2 【基础】安装第三方包的
四
种方法
# 8.2 【基础】安装第三方包的
八
种方法
## 1. 使用 easy_install
...
...
@@ -57,23 +57,65 @@ Success!
安装就可以使用 pipx 安装cli 工具了。
```
shell
# 创建虚拟环境并安装包
$
pipx
install
pkg
```
更多 pipx 的使用方法,可参考本系列教程后面的文章,介绍得非常清楚:
[
12.4 pipx 安装程序的使用指南
](
https://demo.iswbm.com/en/latest/c12/c12_04.html
)
## 4. 使用 yum install
## 4. 使用 setup.py
如果你有编写 setup.py 文件,可以使用如下命令直接安装
```
python
# 使用源码直接安装
$
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`
的包格式。
```
shell
# 发布 rpm 包
$
python setup.py bdist_rpm
```
对于
`rpm`
这种格式,你需要使用
`yum install xxx`
或者
`rpm install xxx`
来安装。
```
shell
# 使用 yum 安装
$
yum
install
pkg
$
rpm
install
pkg
# 使用 rpm 安装
$
rpm
-ivh
pkg
```
## 6. 使用 pipenv
如果你在使用 pipenv 创建的虚拟环境中,可以使用下面这条命令把包安装到虚拟环境中
```
shell
$
pipenv
install
pkg
```
## 7. 使用 poetry
如果你有使用 poetry 管理项目依赖,那么可以使用下面这条命令安装包
```
shell
# 直接安装包
$
poetry add pkg
# 指定为开发依赖
$
poetry add pytest
--dev
```
## 8. 使用 curl + 管道
有一些第三方工具包提供的安装方法,是直接使用 curl 配置管道来安装,比如上面提到的 poetry 就可以用这种方法安装。
```
shell
$
curl
-sSL
https://raw.githubusercontent.com/python-poetry/poetry/master/get-poetry.py | python
```
source/c08/c08_07.md
浏览文件 @
524dc30a
...
...
@@ -6,9 +6,8 @@
```
python
# profile.py
name
=
'wangbm'
age
=
27
gender
=
'male'
name
=
'小明'
age
=
18
__all__
=
[
'name'
]
```
...
...
@@ -18,15 +17,11 @@ __all__=['name']
```
python
>>>
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 *`
这种情况适用。
...
...
source/c12/c12_03.md
浏览文件 @
524dc30a
...
...
@@ -19,7 +19,7 @@
$
brew
install
pipenv
# windows
pip
install
[
--user
]
pipenv
$
pip
install
[
--user
]
pipenv
```
如果你的电脑是 windows 的。
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录