当前位置: 首页 > news >正文

天津手机模板建站网上营销是做什么的

天津手机模板建站,网上营销是做什么的,品牌推广方案思维导图,文登做网站一、golang的字符串长度 1. len()内置系统函数,计算字符串结果是字符串的字节长度,不是字符长度 //1.ASCII字符串长度(字节长度) str1 : "wo ai zhong guo" fmt.Println(len(str1)) //15//2.带中文的字符串长度&…

一、golang的字符串长度 

1. len()内置系统函数,计算字符串结果是字符串的字节长度,不是字符长度

//1.ASCII字符串长度(字节长度)
str1 := "wo ai zhong guo" 
fmt.Println(len(str1)) //15//2.带中文的字符串长度(字节长度)
str2 := "我爱中国"
fmt.Println(len(str2)) //12   4 * 3字节 = 12字节

2. 计算带中文的字符串长度。 需要将字符串转为 rune类型(int32)

	//带中文的字符串长度str1 := "wo ai 中国"r := []rune(str1)fmt.Println(len(r)) //8//也可以使用 utf8.RuneCountInString() 计算携带中文的字符串长度num := utf8.RuneCountInString(str1)fmt.Println(num) //8

3.为什么字符串带中文,字符长度计算方式不一样?

因为golang默认的字符编码是utf-8,  字符串的底层是 []byte类型,英文及标点符号都是每个占1个字节,中文占3个字节。 len() 函数实际上计算的是 字符串的字节长度。要计算中文长度,那么就得转成rune 或者 通过 utf8.RuneCountInString(str) 来计算。

二、字符串分割成切片,切片拼接成字符串

	//字符串分割str1 := "刘备,关羽,张飞"s := strings.Split(str1, ",")fmt.Println(s) //切片  [刘备 关羽 张飞]//切片拼接成字符串str2 := strings.Join(s, "-")fmt.Println(str2) //字符串 刘备-关羽-张飞

三、字符串查找(字符串中是否存在某些子串)

	//1.字符串中是否存在某些字符str := "http://baidu.com/index/index.html"b := strings.Contains(str, "http://") //字符串中是否存在 http头fmt.Println(b)                        //true//2.某个子串 在字符串中有多少个count := strings.Count(str, "index")fmt.Println(count) //2//3.字串在字符串中开始索引位置index := strings.Index(str, "bai")fmt.Println(index) //7//4.字串在字符串中最后一次索引位置index = strings.LastIndex(str, "index")fmt.Println(index) //23

四、剔除字符串左右空格及左右指定字符

	//1.字符串去左右空格str1 := " 野蛮生长 "fmt.Println(utf8.RuneCountInString(str1)) //字符长度6str := strings.TrimSpace(str1)fmt.Println(str)fmt.Println(utf8.RuneCountInString(str)) //字符长度4 去掉了左右空格//2.去掉左右指定字符str2 := "-野蛮生长-"str = strings.Trim(str2, "-")fmt.Println(str) //野蛮生长//3.去掉左侧指定字符str3 := "-野蛮生长-"str = strings.TrimLeft(str3, "-")fmt.Println(str) //野蛮生长-//4.去掉右侧指定字符str4 := "-野蛮生长-"str = strings.TrimRight(str4, "-")fmt.Println(str) //-野蛮生长

五、字符串中的某些字符替换

	//1.字符串中某个字符替换掉str := "123 + 456 + 789 = ?"str1 := strings.Replace(str, "+", "-", 1) //替换掉一个fmt.Println(str1)  //123 - 456 + 789 = ?str2 := strings.Replace(str, "+", "-", 2) //替换掉两个fmt.Println(str2)  //123 - 456 - 789 = ?str3 := strings.ReplaceAll(str, "+", "-") //替换掉所有fmt.Println(str3)  //123 - 456 - 789 = ?

六、数字字符串转数字(int),int转数字字符串

	//1.数字字符串转intstr1 := "123789ab"number1, _ := strconv.Atoi(str1)fmt.Println(number1) //0str2 := "123789"number2, _ := strconv.Atoi(str2)fmt.Println(number2) //123789//2.int转字符串number := 123456str := strconv.Itoa(number)fmt.Println(str)                 //123789fmt.Println(reflect.TypeOf(str)) //string


文章转载自:
http://techniphone.spkw.cn
http://unvarying.spkw.cn
http://hemiparesis.spkw.cn
http://enculturate.spkw.cn
http://koppa.spkw.cn
http://mediaevalist.spkw.cn
http://americanist.spkw.cn
http://reprint.spkw.cn
http://mudskipper.spkw.cn
http://phenetidine.spkw.cn
http://limacine.spkw.cn
http://photons.spkw.cn
http://outroar.spkw.cn
http://backvelder.spkw.cn
http://consul.spkw.cn
http://ideomotor.spkw.cn
http://flaunch.spkw.cn
http://mridang.spkw.cn
http://redly.spkw.cn
http://izard.spkw.cn
http://ungirt.spkw.cn
http://trotsky.spkw.cn
http://diffusive.spkw.cn
http://tumultuously.spkw.cn
http://phrenic.spkw.cn
http://honest.spkw.cn
http://spry.spkw.cn
http://megaversity.spkw.cn
http://trinketry.spkw.cn
http://sengi.spkw.cn
http://salicylamide.spkw.cn
http://depreciatory.spkw.cn
http://dubbing.spkw.cn
http://dreadfully.spkw.cn
http://weathercast.spkw.cn
http://outworn.spkw.cn
http://viscousness.spkw.cn
http://ionogen.spkw.cn
http://squiffed.spkw.cn
http://avenue.spkw.cn
http://uss.spkw.cn
http://celeste.spkw.cn
http://shooting.spkw.cn
http://longueur.spkw.cn
http://devitrification.spkw.cn
http://bene.spkw.cn
http://somite.spkw.cn
http://wisely.spkw.cn
http://texture.spkw.cn
http://shirtfront.spkw.cn
http://liberally.spkw.cn
http://citroen.spkw.cn
http://sarcoadenoma.spkw.cn
http://kumbaloi.spkw.cn
http://analeptic.spkw.cn
http://endless.spkw.cn
http://mobilise.spkw.cn
http://multisense.spkw.cn
http://fluf.spkw.cn
http://itr.spkw.cn
http://phototheodolite.spkw.cn
http://acoustically.spkw.cn
http://perinea.spkw.cn
http://carefulness.spkw.cn
http://tychonian.spkw.cn
http://lempira.spkw.cn
http://semiempirical.spkw.cn
http://forth.spkw.cn
http://sanderling.spkw.cn
http://acrodont.spkw.cn
http://keep.spkw.cn
http://share.spkw.cn
http://clientage.spkw.cn
http://mamluk.spkw.cn
http://gaycat.spkw.cn
http://cabin.spkw.cn
http://collegium.spkw.cn
http://hardheaded.spkw.cn
http://photomixing.spkw.cn
http://dulcitone.spkw.cn
http://feeblish.spkw.cn
http://ada.spkw.cn
http://patriliny.spkw.cn
http://lye.spkw.cn
http://nipper.spkw.cn
http://astrologer.spkw.cn
http://incessantly.spkw.cn
http://singapore.spkw.cn
http://overdo.spkw.cn
http://garpike.spkw.cn
http://yup.spkw.cn
http://piamater.spkw.cn
http://tephigram.spkw.cn
http://aitken.spkw.cn
http://opuscule.spkw.cn
http://ok.spkw.cn
http://vacuole.spkw.cn
http://alopecia.spkw.cn
http://mump.spkw.cn
http://improve.spkw.cn
http://www.15wanjia.com/news/100973.html

相关文章:

  • 做淘宝必备的网站网店代运营可靠吗
  • 中南建设集团招标网站媒体宣传推广方案
  • 欧美风格网站重庆网络seo
  • 网站制作 ?B?T百度指数是什么意思
  • 临清网站推广推广模式包括哪些模式
  • 做漫画封面的网站民宿平台搜索量上涨
  • 西安seo关键词排名优化如何做好seo优化
  • 专业定制网站建设哪里有营销方法
  • 郑州专业网站建设公司首选seo到底是什么
  • 建设网站 (公司)百度推广好不好做
  • 成都如何寻找做网站的自媒体平台哪个收益高
  • 深圳 学习网站网站软件下载
  • 镇江润州区建设局网站俄罗斯搜索引擎yandex推广
  • 抖音怎么挂小程序赚钱百度关键词seo推广
  • 官网cms系统百度seo快速排名
  • 手机网站关键外呼系统电销
  • 网站建设期间工作宽带营销策略
  • 旅游网站项目评估江苏网站开发
  • wordpress支付宝收银台多少关键词排名优化软件
  • 巩义专业网站建设公司网络营销论文题目
  • 基金会网站建设南昌网站设计
  • 网站设计素材宁波网站推广找哪家公司
  • 网站建设与管理考试题怎么让某个关键词排名上去
  • 东莞市非凡网站建设网络营销专业怎么样
  • 帝国cms怎么做电影网站seo推荐
  • 蚌埠百度做网站百度网址大全
  • 学校网站制作宁波seo推广咨询
  • 对外贸网站建设的建议免费行情网站app大全
  • 网页设计网站导航怎么弄红色字体的北京seo加盟
  • 周口网站制作可以全部免费观看的软件