文字列操作
Repeat¶
s := "a"
strings.Repeat(s, 2)
s = "a"
s * 2
Result:¶
aa
HasPrefix¶
a, b := "Gopher", "Go"
strings.HasPrefix(a, b)
a, b = "Gopher", "Go"
a.startswith(b)
Result:¶
true
HasSuffix¶
a, b := "Python", "on"
strings.HasSuffix(a, b)
a, b = "Python", "on"
a.endswith(b)
Result:¶
true