网站首页 » Golang » Golang 字符串截取

Golang 字符串截取

June 27, 2020 Golang

截取英文字符串

s := "golang hello world"
str := s[:3]

截取中文字符串

s := "hello world 你好啊"
str := string([]rune(s)[:8])
添加新评论