首页 > 其他 > 详细

go不使用工具包将大写字符转成小写字符的方法

时间:2019-03-21 00:36:04      阅读:129      评论:0      收藏:0      [点我收藏+]

 

package main

import (
    "fmt"
)

func main() {
    str := "hellOWorlD" //返回str is all lower char
    b := make([]byte, len(str))
    for i, _:= range str{
        s := str[i]
        if A <= s && s <= Z {
            s = s - A + a
        }
        b[i] = s
    }
    fmt.Println(str) //返回hellOWorlD
    fmt.Printf("%s\n",b) //返回helloworld
}

 

go不使用工具包将大写字符转成小写字符的方法

原文:https://www.cnblogs.com/wanghui-garcia/p/10568991.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!