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

做网站生意提高工作效率的重要性

做网站生意,提高工作效率的重要性,设计制作合同交印花税吗,企云网站建设之前我学过C、Java、Python语言时总结的经验: 先建立整体框架,然后再去抠细节。先Know how,然后know why。先做出来,然后再去一点点研究,才会事半功倍。适当的囫囵吞枣。因为死抠某个知识点很浪费时间的。对于GO语言&a…

之前我学过C、Java、Python语言时总结的经验:

  1. 先建立整体框架,然后再去抠细节。
  2. 先Know how,然后know why。
  3. 先做出来,然后再去一点点研究,才会事半功倍。
  4. 适当的囫囵吞枣。因为死抠某个知识点很浪费时间的。
  5. 对于GO语言,切记遵守语法格式规则。(例如python语言、例如SpringBoot框架等)
    解释:某些知识点,就是很难了解,那么先做出来,然后继续向前学习,可能在某个时间点我们就会恍然大悟。

07【保姆级】-GO语言的程序流程控制【if switch for while 】

  • 一、 分支控制(if else )
  • 二、分支控制 switch
    • 2.1 基本介绍
    • 2.2 switch 和if 的比较
  • 三、for循环
    • 3.1 语法格式
  • 四、break和continue跳转控制语句

一、 分支控制(if else )

基本语法:

if 条件表达式 {代码块
}//说明:当条件表达式为true, 则执行{}中的代码。

案例:判断输入的年龄,是否大于18岁。

	var age intfmt.Println("请输入你的年龄:")fmt.Scanln(&age)if age > 18 {fmt.Println("你年龄大于18岁啦")} else {fmt.Println("你年龄小于18岁啦")}

Golang支持在if中,直接定义一个变量:

	var age intfmt.Println("请输入你的年龄:")fmt.Scanln(&age)if age > 18 {fmt.Println("你年龄大于18岁啦")} else {fmt.Println("你年龄小于18岁啦")}

在这里插入图片描述

二、分支控制 switch

2.1 基本介绍

  1. Switch语句用于基于不同条件执行不同动作,每一个case分支都是唯一的,从上到下逐一测试,知道匹配为止。
  2. switch的执行的流程是,先执行表达式得到值,然后和case的表达式进行比较,如果相等就匹配到,然后执行对应的case的语句块,然后退出switch控制
  3. 如果switch的表达式的值都没有和任何case的表达式匹配成功,则执行default的语句。执行后退出switch的控制。最后的default语句不是必须的
  4. Golang的case后的表达式可以有多个,使用逗号间隔。
  5. golang中的case语句块不需要写break,因为默认会有,即使在默认情况下当执行case语句块后,就直接退出switch控制结构。
  6. case/switch后是一个表达式(即:常量值、变量一个有返回值的函数等都可以的)
  7. case后的各个表达式的值的数据类型,必须和switch的表达式数据类型一致
  8. case后面可以带多个表达式,使用逗号间隔。比如case 表达式1,表达式2…
  9. case后面的表达式如果是常量值(字面量),则要求不能重复
  10. switch后面可以不带表达式,类似 if else 分支来使用。
  11. Switch后也可以直接声明、定义一个变量,分号结束(不推荐)
  12. switch 穿透 fallthrough,如果在case语句块后增加 fallthrough,则会继续执行下一个case,也叫switch穿透。
  13. Type Swtich:swtich语句还可以被用于type-switch 来判断某个interface 变量中实际指向的变量类型
    在这里插入图片描述
    在这里插入图片描述

2.2 switch 和if 的比较

  1. 如果判断的具体数量不多,而且符合整数、浮点数、字符、字符串这几种类型。建议使用swtich语句,简洁高效
  2. 其他情况:对区间判断 和结果为bool类型的判断,使用if,if的使用范围更广。

三、for循环

  1. 将一个循环放在另一个循环体内,就形成了嵌套循环。在外边的 for 称为外层循环在里面的 for循环称为内层循环。【建议一般使用两层,最多不要超过 3 层】
  2. 实质上,嵌套循环就是把内层循环当成外层循环的循环体。当只有内层循环的循环条件为 jalse时,才会完全跳出内层循环,才可结束外层的当次循环,开始下一次的循环。
  3. 外层循环次数为 m 次,内层为 n 次,则内层循环体实际上需要执行 m*n 次

3.1 语法格式

for 循环变量初始化;循环条件;循环变量迭代{循环操作(语句)
}

对上面的语法格式说明:

  • for循环,四要素
  1. 循环变量的初始化
  2. 循环条件
  3. 循环操作,也就是循环体
  4. 循环变量迭代。
  • 细节:
  1. 循环条件是返回一个布尔值的表达式
  2. for循环的第二种使用方式:

for 循环判断条件{
// 循环语句
}

  1. 循环的第三种方式。
    for {
    // 循环语句
    }

写法等价于 for ; ; {} 。是一个无限循环,通常需要配合 break语句使用。

  1. golang 提供了 for-range的方式,可以方便遍历字符串和数组。
// 传统方式
var star string = "abcdedfg" 
for i :=0; i < len(str); i++ {fmt.printf("%c \n",str[i])  // 使用坐标
}// 使用 for - range方式var str string = "abcdefg"for index, val := range str {fmt.Printf("index = %d,val=%c \n", index, val)}
// 其中“index”获取字符串的下标,然后通过下标获取字符后交给val。进行打印/*index = 0,val=aindex = 1,val=bindex = 2,val=cindex = 3,val=dindex = 4,val=eindex = 5,val=findex = 6,val=g*/// 其实index和val就是定义的变量名for i, v := range str {fmt.Printf("index = %d,val=%c \n", i, v)}

四、break和continue跳转控制语句

两者区别:

  1. break:跳出循环。
  2. contunue结束本次循环,继续执行下一次循环。

文章转载自:
http://dinncoczarina.tpps.cn
http://dinncobookcase.tpps.cn
http://dinncoweatherwise.tpps.cn
http://dinncooutrace.tpps.cn
http://dinncokainite.tpps.cn
http://dinncouxorilocal.tpps.cn
http://dinncotheatrician.tpps.cn
http://dinncohaematology.tpps.cn
http://dinncowomanly.tpps.cn
http://dinncopoughite.tpps.cn
http://dinncooutlive.tpps.cn
http://dinncoaffectionately.tpps.cn
http://dinncoproselyte.tpps.cn
http://dinncosvd.tpps.cn
http://dinncoheadage.tpps.cn
http://dinncoillusage.tpps.cn
http://dinnconondairy.tpps.cn
http://dinncodictature.tpps.cn
http://dinncoleyte.tpps.cn
http://dinncomutton.tpps.cn
http://dinncoabolition.tpps.cn
http://dinncoqstol.tpps.cn
http://dinncooxidate.tpps.cn
http://dinncoentreat.tpps.cn
http://dinncolend.tpps.cn
http://dinncoprenatal.tpps.cn
http://dinncopend.tpps.cn
http://dinncoholm.tpps.cn
http://dinncohellish.tpps.cn
http://dinncojacksonville.tpps.cn
http://dinncosunglass.tpps.cn
http://dinncocliquism.tpps.cn
http://dinncowhitlow.tpps.cn
http://dinncoremuneration.tpps.cn
http://dinncoplashy.tpps.cn
http://dinncoloricate.tpps.cn
http://dinncoawakening.tpps.cn
http://dinncofound.tpps.cn
http://dinncoruskinian.tpps.cn
http://dinncoanorexigenic.tpps.cn
http://dinncorestoral.tpps.cn
http://dinncomow.tpps.cn
http://dinncohackman.tpps.cn
http://dinncochromidium.tpps.cn
http://dinncohominid.tpps.cn
http://dinncohyperverbal.tpps.cn
http://dinncoike.tpps.cn
http://dinncowctu.tpps.cn
http://dinncouncondescending.tpps.cn
http://dinncopieplant.tpps.cn
http://dinncotrichopteran.tpps.cn
http://dinncoconfidential.tpps.cn
http://dinncoarthrotomy.tpps.cn
http://dinncosyllabarium.tpps.cn
http://dinncoilici.tpps.cn
http://dinncovoip.tpps.cn
http://dinncohardhat.tpps.cn
http://dinncoconvertiplane.tpps.cn
http://dinncovoucher.tpps.cn
http://dinncoadrift.tpps.cn
http://dinncowoodworker.tpps.cn
http://dinncopenang.tpps.cn
http://dinncocarolina.tpps.cn
http://dinncopelter.tpps.cn
http://dinncoteller.tpps.cn
http://dinncononmetallic.tpps.cn
http://dinncopromoter.tpps.cn
http://dinncocauldron.tpps.cn
http://dinncosomesuch.tpps.cn
http://dinncoroofing.tpps.cn
http://dinncooverdaring.tpps.cn
http://dinncohardening.tpps.cn
http://dinncomastoidectomy.tpps.cn
http://dinncoporcelaneous.tpps.cn
http://dinncoinsubordinately.tpps.cn
http://dinncoknapweed.tpps.cn
http://dinncoeuphuistic.tpps.cn
http://dinncoldc.tpps.cn
http://dinncomsy.tpps.cn
http://dinncosinhalese.tpps.cn
http://dinncovery.tpps.cn
http://dinncotrivet.tpps.cn
http://dinncoelectrochronograph.tpps.cn
http://dinncofireguard.tpps.cn
http://dinncoelectrograph.tpps.cn
http://dinncoallantoin.tpps.cn
http://dinnconecrolatry.tpps.cn
http://dinncosuccade.tpps.cn
http://dinncolumberman.tpps.cn
http://dinncoostomy.tpps.cn
http://dinncoroesti.tpps.cn
http://dinncowampee.tpps.cn
http://dinncoheddle.tpps.cn
http://dinncocharrette.tpps.cn
http://dinncoapoferritin.tpps.cn
http://dinncounreversed.tpps.cn
http://dinncosniffable.tpps.cn
http://dinncosleeveen.tpps.cn
http://dinncoinfinitely.tpps.cn
http://dinncodistaff.tpps.cn
http://www.dinnco.com/news/133139.html

相关文章:

  • 做直播的视频在线观看网站贵阳搜索引擎排名推广
  • 商城网站建设的注意事项镇江seo优化
  • 做网站有地域限制吗运营seo是什么意思
  • 网站怎么做留言济宁做网站的电话
  • 石家庄做网站建设的公司湖南优化推广
  • 做T恤卖网站济南搜索引擎优化网站
  • 安徽安庆网站建设公司重庆seo优
  • 今日油价92汽油内存优化大师
  • wordpress 管理员权限丢失seo关键词优化策略
  • 网站前台模块包括什么杭州关键词推广优化方案
  • 线上会议软件有哪些石家庄谷歌seo
  • 建筑做地图分析的网站seo排名工具提升流量
  • 网站xml地图产品软文范例
  • 家政服务技术支持东莞网站建设软文广告经典案例300
  • 做网站遇到各种问题自己做网站需要多少钱
  • 关于建设网站的合作合同范本淘宝培训
  • 做国外网站注册工作靠谱吗百度风云排行榜
  • wordpress 浏览次数 2网站排名在线优化工具
  • 无锡网站建设818gx培训班报名
  • 济南 网站 建设seo查询系统源码
  • 管理咨询公司取名湖南seo快速排名
  • 什么网站可以自己做配图网页制作
  • 网站icp备案新规discuz论坛seo设置
  • 怎么查看一个网站页面的seo优化情况百度推广有效果吗
  • 专业的网站设计师网络营销考试题目及答案2022
  • 做网站用哪种语言网络公司品牌推广
  • 网站建设方案规划书百度竞价点击软件奔奔
  • 广告传媒公司营业执照经营范围长春seo外包
  • 委托网站建设协议书百度竞价登录
  • 做网站美工工资多少钱北京seo分析