代码点读机 / Go / strings

strings Go · 常用包

Go 标准库里的字符串工具包:提供查找、分割、替换、大小写转换等常用字符串操作。

怎么用

import "strings"; strings.函数(字符串, ...) 处理文本

小例子

package main
import (
    "fmt"
    "strings"
)

func main() {
    fmt.Println(strings.ToUpper("go"))
}

运行结果

输出 GO

提醒:字符串在 Go 中不可变,所有修改类操作都返回新字符串

官方文档:https://pkg.go.dev/strings

在代码里遇到不认识的词?打开代码点读机,点一下就懂 → ← Go全部词条