一、用法

range类似迭代器,可以遍历数组,字符串,map等等,对象的不同,返回的结果也不同。

package main
import "fmt"
func main(){
    //数组的遍历
    a := [3]int {1, 2, 3}
    for i, n := range a{
        fmt.Println(i, n)
    }
    //切片的遍历
    b := []int{2, 3, 4}
    for i, n := range b{
        fmt.Println(i, n)
    }
    //map的遍历
    c := map[string]int{"Hello":1, "World":2}
    for k, v := range c{
        fmt.Println(k, v)
    }
}

- 阅读剩余部分 -

一、概述

学习git 的第一步,肯定是要知道如何创建版本库,但是在这之前,还要搞清楚的一组概念是git 中的工作区寄存区版本库

  • 工作区:工作区是我们的项目工作目录,也是git初始化时的目录,将来所有的代码文件都保存在这个目录中。
  • 寄存区:在工作区完成代码编辑后,首先要使用add命令把代码提交到寄存区中,寄存区的数据存放在<span style="text-indent: 2em;">.git/index目录下,所以有时候也把寄存区叫索引区。
  • 版本库:代码提交到寄存区后,需要通过commit命令把代码提交到版本库,只有经历了这一步之后代码才算是真正存放到了git仓库中。

- 阅读剩余部分 -

一、概述

Git 的默认配置信息保存在~/.gitconfig 文件下,初始化的时候为空,根据需要添加。

二、配置用户信息

用户信息就相当于QQ或是微信里的用户名一样,标志用户的身份。

需要配置的是nameemail

git config --global user.name "maqian"
git config --global user.email maqian@dyxmq.cn

- 阅读剩余部分 -

把CentOS6.5默认的python2.6升级到了python2.7,然后运行yum命令的时候就出现了错误:

There was a problem importing one of the Python modules
required to run yum. The error leading to this problem was:
   No module named yum
Please install a package which provides this module, or
verify that the module is installed correctly.
It"s possible that the above module doesn"t match the
current version of Python, which is:
2.7.13 (default, Aug 18 2017, 21:52:09) 
[GCC 4.4.7 20120313 (Red Hat 4.4.7-18)]
If you cannot solve this problem yourself, please go to 
the yum faq at:
  http://yum.baseurl.org/wiki/Faq

- 阅读剩余部分 -