美文网首页
【每天一个Go知识点】(1) Go语言转换所有字符串为大写或者

【每天一个Go知识点】(1) Go语言转换所有字符串为大写或者

作者: HAO延WEI | 来源:发表于2021-05-31 14:58 被阅读0次

Go语言的string模块包含了ToLower和ToUpper函数,用于将字符串转换成小写和大写

package main

import (
  "fmt"
  "strings"
)

func main() {

  fmt.Println(strings.ToUpper("hello world")) // 将字符串转化为大写
  fmt.Println(strings.ToLower("HELLO WORLD")) // 将字符串转化为小写
}

相关文章

网友评论

      本文标题:【每天一个Go知识点】(1) Go语言转换所有字符串为大写或者

      本文链接:https://www.haomeiwen.com/subject/yswdsltx.html