blog:python:string

差别

这里会显示出您选择的修订版和当前版本之间的差别。

到此差别页面的链接

两侧同时换到之前的修订记录 前一修订版
blog:python:string [2022/09/12 09:34] – [字符串] caodanblog:python:string [2023/05/19 20:21] (当前版本) – [字符串截取操作] caodan
行 6: 行 6:
  
 例如: `str="I'm \"tux\""` 例如: `str="I'm \"tux\""`
- 
 ## 字符串截取操作 ## 字符串截取操作
  
行 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        | the last character                                            |
 | `str[:]`    | abcdefg  | all the characters                                            | | `str[:]`    | abcdefg  | all the characters                                            |
 | `str[::-1]` | gfedcba  | `[::-1]` 字符串最后一个字符到第一个字符,也就是对字符串逆序   | | `str[::-1]` | gfedcba  | `[::-1]` 字符串最后一个字符到第一个字符,也就是对字符串逆序   |
  • blog/python/string.txt
  • 最后更改: 2023/05/19 20:21
  • caodan