A~Z :65~90a~z :97~1220~9 : 48~57
如果想要知道字符串中的值是否是⼩写英⽂字符,不使⽤⼯具包的⼀种⽅法就是使⽤Unicode编码值,举例:
package mainimport ( \"fmt\")
func main() {
// str := \"helloworld\" //返回str is all lower char str := \"hello4world\" //返回str is not all lower char for _, s := range str{
if !(s > 96 && s < 123){
fmt.Println(\"str is not all lower char\") return } }
fmt.Println(\"str is all lower char\")}
当然还有更简单的⼀种⽅法:
package mainimport ( \"fmt\")
func main() {
str := \"helloworld\" //返回str is all lower char
// str := \"hello4world\" //返回str is not all lower char for _, s := range str{
if !('a' <= s && s <= 'z'){
fmt.Println(\"str is not all lower char\") return } }
fmt.Println(\"str is all lower char\")}
因篇幅问题不能全部显示,请点此查看更多更全内容
Copyright © 2019- sceh.cn 版权所有 湘ICP备2023017654号-4
违法及侵权请联系:TEL:199 1889 7713 E-MAIL:2724546146@qq.com
本站由北京市万商天勤律师事务所王兴未律师提供法律服务