标签:pac imp code 连续 ring 错误 aaaaaa pack replace
package main
import (
"fmt"
"strings"
"strconv"
)
func main() {
var str = `
床前明月光,
疑是地上霜。
`
fmt.Println(str)
var a = "66666"
fmt.Println(a)
fmt.Println(strings.Fields("abc def ghi"))
//替换两边的a(可以是连续多个a)
fmt.Println(strings.Trim("aabbaabcbbaa","a"))
//替换所有a,b
fmt.Println(strings.Trim("abbaabcbba","ab"))
//替换左边的ab(可以是连续多个a或b)
fmt.Println(strings.TrimLeft("abbaabcbba","ab"))
//替换右边的ab(可以是连续多个a或b)
fmt.Println(strings.TrimRight("abbaabcbba","ab"))
fmt.Println(strings.Split("ab,ba,ab,cb,ba",","))
fmt.Println(strings.Join([]string{"ab", "ba", "ab", "cb", "ba"},","))
fmt.Println(strings.Repeat("A", 6))
//-1替换所有,0不替换,大于零的整数n为前n个
fmt.Println(strings.Replace("aabbccddeeaabb","a", "*", 0))
//字符串出现的次数
fmt.Println(strings.Count("abcdabefab", "ab"))
fmt.Println(strings.ToLower("ABC"))
fmt.Println(strings.ToUpper("abc"))
//整数转换字符转
fmt.Println(strconv.Itoa(1))
//字符串转换整数(返回两个值:转换后的值和错误)
fmt.Println(strconv.Atoi("666"))
}
输出:
床前明月光,
疑是地上霜。
66666
[abc def ghi]
bbaabcbb
c
cbba
abbaabc
[ab ba ab cb ba]
ab,ba,ab,cb,ba
AAAAAA
aabbccddeeaabb
3
abc
ABC
1
666 <nil>
Process finished with exit code 0
标签:pac imp code 连续 ring 错误 aaaaaa pack replace
原文地址:http://blog.51cto.com/5660061/2345351