Go 字符串替换


package main
 
import (
    "fmt"
    "strings"
)
 
func main() {
    str := "welcome to beijing"
    strF = strings.Replace(str, " ", ",", -1)
    fmt.Println(strF)
    strS = strings.Replace(str, " ", ",", 1)
    fmt.Println(strS)
}
分享:

评论