doc: update docs/python.md

This commit is contained in:
jaywcjlove 2023-08-15 00:15:01 +08:00
parent 4020036f93
commit 86d4e8bea5

View File

@ -425,6 +425,19 @@ txt2 = "My name is {0}, I'm {1}".format("John", 36)
txt3 = "My name is {}, I'm {}".format("John", 36)
```
### 转义符号
<!--rehype:wrap-class=row-span-2-->
| 转义符号 | 对应的操作 |
|------|--------|
| `\\` | 输出反斜杠 |
| `\'` | 输出单引号 |
| `\"` | 输出双引号 |
| `\n` | 换行 |
| `\t` | 水平制表符 |
| `\r` | 光标回到首位 |
| `\b` | 退格 |
### 控制台输入
```python
@ -436,14 +449,8 @@ Enter your name: Tom
从控制台获取输入数据
### 插入分隔符拼接
```python
>>> "、".join(["John", "Peter", "Vicky"])
'John、Peter、Vicky'
```
### 头尾判断
<!--rehype:wrap-class=row-span-2-->
```python
>>> # 是否以 H 开头
@ -457,17 +464,12 @@ False
True
```
### 转义符号
### 插入分隔符拼接
| 转义符号 | 对应的操作 |
|------|--------|
| `\\` | 输出反斜杠 |
| `\'` | 输出单引号 |
| `\"` | 输出双引号 |
| `\n` | 换行 |
| `\t` | 水平制表符 |
| `\r` | 光标回到首位 |
| `\b` | 退格 |
```python
>>> "、".join(["John", "Peter", "Vicky"])
'John、Peter、Vicky'
```
Python f-字符串 (Python 3.6+)
----------------