差别
这里会显示出您选择的修订版和当前版本之间的差别。
两侧同时换到之前的修订记录 前一修订版 | |||
blog:python:string [2022/09/12 09:34] – [字符串] caodan | blog:python:string [2023/05/19 20:21] (当前版本) – [字符串截取操作] caodan | ||
---|---|---|---|
行 6: | 行 6: | ||
例如: `str=" | 例如: `str=" | ||
- | |||
## 字符串截取操作 | ## 字符串截取操作 | ||
行 22: | 行 21: | ||
| `str[4:] ` | efg | characters from position 4 to the end | | | `str[4:] ` | efg | characters from position 4 to the end | | ||
| `str[-2:] ` | fg | characters from the second last to the end | | | `str[-2:] ` | fg | characters from the second last to the end | | ||
- | | `str[-1:] ` | fg | the last character | + | | `str[-1:] ` | f |
| `str[: | | `str[: | ||
| `str[::-1]` | gfedcba | | `str[::-1]` | gfedcba |