1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
| package main
import (
"fmt"
"strconv"
"strings"
)
func main() {
test := "applelemonapplemon"
fmt.Println(strings.Contains(test, "apple"))
test2 := []string{"apple", "lemon", "melon"}
fmt.Println(strings.Join(test2, ","))
test3 := "applelemonapplemon"
fmt.Println(strings.Index(test3, "apple"))
fmt.Println(strings.Repeat("apple", 3))
test4 := "applelemonapple"
fmt.Println(strings.Replace(test4, "apple", "", -1))
test5 := "test,test1,test2"
fmt.Println(strings.Split(test5, ","))
test6 := " aaatest, spaces "
fmt.Println(test6)
fmt.Println(strings.Trim(test6, " "))
test7 := "a b c d e f"
fmt.Println(strings.Fields(test7))
str := make([]byte, 0, 100)
str = strconv.AppendInt(str, 4567, 10)
str = strconv.AppendBool(str, false)
str = strconv.AppendQuote(str, "abcdefg")
str = strconv.AppendQuoteRune(str, '单')
fmt.Println(string(str))
a := strconv.FormatBool(false)
b := strconv.FormatFloat(123.23, 'g', 12, 64)
c := strconv.FormatInt(1234, 10)
d := strconv.FormatUint(12345, 10)
e := strconv.Itoa(1023)
fmt.Println(a, b, c, d, e)
f, _ := strconv.ParseBool("false")
g, _ := strconv.ParseFloat("123.23", 64)
h, _ := strconv.ParseInt("1234", 10, 64)
i, _ := strconv.ParseUint("12345", 10, 64)
j, _ := strconv.Atoi("1023")
fmt.Println(f, g, h, i, j)
}
|