Last active
December 16, 2015 04:29
-
-
Save viney/5377609 to your computer and use it in GitHub Desktop.
go语言分离字符串
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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