第十七十八章 (#833)

Co-authored-by: Joe Chen <jc@unknwon.io>
This commit is contained in:
Haigang Zhou
2022-05-19 19:57:23 +08:00
committed by GitHub
parent 72bc74ab95
commit fa1cfcc67f
12 changed files with 66 additions and 67 deletions

View File

@@ -30,20 +30,19 @@ for ix, ch := range str {
4如何获取一个字符串的字节数`len(str)`
如何获取一个字符串的字符数:
如何获取一个字符串的字符数:
最快速:`utf8.RuneCountInString(str)`
(最快速)使用 `utf8.RuneCountInString(str)`
`len([]rune(str))`
或使用 `len([]rune(str))`
5如何连接字符串
最快速:
`with a bytes.Buffer`(参考[章节7.2](07.2.md)
(最快速)使用 `bytes.Buffer`(参考[章节 7.2](07.2.md)
`Strings.Join()`(参考[章节4.7](04.7.md)
使用 `+=`
或使用 `Strings.Join()`(参考[章节 4.7](04.7.md)
使用 `+=`
```go
str1 := "Hello "
@@ -51,9 +50,7 @@ for ix, ch := range str {
str1 += str2 //str1 == "Hello World!"
```
6如何解析命令行参数使用 `os` 或者 `flag` 包
(参考[例12.4](examples/chapter_12/fileinput.go)
6如何解析命令行参数使用 `os` 或者 `flag` 包(参考[例 12.4](examples/chapter_12/fileinput.go)
## 链接