package main

import "fmt"

func main() {
  s := "Hello World!"
  fmt.Println(s[0]) //使用下标索引 72

  fmt.Println(s[:5])//切片 hello
}

字符串 中截取的

索引获取字符串对应位置上存储的字节值,使用切片操作符获取字符串的一个子串

 

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-06-03
  • 2022-12-23
  • 2021-04-11
  • 2021-08-18
  • 2021-07-07
猜你喜欢
  • 2022-12-23
  • 2021-05-28
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-08-03
相关资源
相似解决方案