replace.go 299 B

12345678910111213141516
  1. package main
  2. import (
  3. "fmt"
  4. "github.com/tal-tech/go-zero/core/stringx"
  5. )
  6. func main() {
  7. replacer := stringx.NewReplacer(map[string]string{
  8. "日本": "法国",
  9. "日本的首都": "东京",
  10. "东京": "日本的首都",
  11. })
  12. fmt.Println(replacer.Replace("日本的首都是东京"))
  13. }