Skip to content

Commit 735496e

Browse files
author
ghy
authored
Update basic-types.md (#22)
1 parent 123d3c9 commit 735496e

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

i18n/zh-cn/docusaurus-plugin-content-docs/current/basic-types.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,8 +71,8 @@ print(type(name)) # 获取变量的类型
7171
| 是否以指定字符结尾 | `myStr.endsWith(suffix)` | `my_str.endswith(suffix)` |
7272
| 删除两端的空白字符 | `myStr.trim()` | `my_str.strip()` |
7373
| 按指定宽度居中对齐 | - | `my_str.center(width)` |
74-
| 第一个单词首字母大写 | - | `my_str.capitalize()` |
75-
| 每个单词首字母大写 | - | `my_str.title()` |
74+
| 第一个单词首字母大写 | `myStr.replace(myStr[0], myStr[0].toUpperCase())` | `my_str.capitalize()` |
75+
| 每个单词首字母大写 | `myStr.replace(/(^\w{1})|(\s+\w{1})/g, s => s.toUpperCase())` | `my_str.title()` |
7676

7777
### 相关资源
7878
- https://docs.python.org/3/library/stdtypes.html

0 commit comments

Comments
 (0)