4.go开源groupcache项目笔记——关于strconv

       Strconv包是赋值将string进行转换的,例如将字符串转换为整型数字等。

1      测试代码

packagemain

 

import(

    "fmt"

    "strconv"

)

 

funcmain(){

    varorigstring="666"

    varanint

    varnewSstring

 

    fmt.Printf("Thesizeofintsis:%d\n",strconv.IntSize)

 

    an,_=strconv.Atoi(orig)

    fmt.Printf("Theintegeris:%d\n",an)

    an=an+5

    newS=strconv.Itoa(an)

    fmt.Printf("Thenewstringis:%s\n",newS)

}

2      执行结果

The size of ints is: 64

The integer is: 666

The new string is: 671