Go语言string,int,int64 ,float之间类型转
2018-06-27 本文已影响10人
caoxinyiyi
//string到int
int,err:=strconv.Atoi(string)
//int到string
string:=strconv.Itoa(int)
//string到int64
int64, err := strconv.ParseInt(string, 10, 64)
//int64到string
string:=strconv.FormatInt(int64,10)
//string到float32(float64)
float,err := strconv.ParseFloat(string,32/64)
//float到string
string := strconv.FormatFloat(float32, 'E', -1, 32)
string := strconv.FormatFloat(float64, 'E', -1, 64)