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 }
原文地址:https://www.cnblogs.com/wanghui-garcia/p/10568991.html
时间: 2024-10-10 09:37:15