#string到int
int,err:=strconv.Atoi(string)
#string到int64
int64, err := strconv.ParseInt(string, 10, 64)
// 通过Sprintf方法转换
str2 := fmt.Sprintf("%d", i) //其实%v也可以
示例:
time1 := time.Now().Unix()
s3 := fmt.Sprintf("%v", time1 )
s4 := fmt.Sprint(time1)
fmt.Println(s3+"___"+s4)
//1257894000___1257894000
#int到string
string:=strconv.Itoa(int)
#int64到string
string:=strconv.FormatInt(int64,10)
|