Skip to content

Instantly share code, notes, and snippets.

@viney
Last active December 16, 2015 04:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save viney/5377609 to your computer and use it in GitHub Desktop.
Save viney/5377609 to your computer and use it in GitHub Desktop.
go语言分离字符串
package main
import (
"fmt"
"strings"
)
func main() {
// 第一种方式
ss := "ex:fx:tx"
array := strings.Split(ss, ":")
fmt.Println(array[0], array[1], array[2])
// 第二种方式
for _, v := range array {
fmt.Println(v)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment