golang 截取 字符串

For string operation, the string is taken a common,

When you need to intercept a portion of the string, as may be used to operate as a part of the array taken, the following sample code:

package main
 
import "fmt"
 
func main() { 
  str := "XBodyContentX"
  content := str[1 : len(str)-1]
  fmt.Println(content)
}

Run results: BodyContent

Guess you like

Origin www.cnblogs.com/enumx/p/12322441.html