Go int, int64,string 互相转换

329 阅读1分钟

int int64 string 互相转换

// string to int
a, err := strconv.Atoi("123456") // a = 123456(int)

// string to int64
b, err := strconv.ParseInt("1234567890123456", 10, 64) // b = 1234567890123456(int64)

// int to string
c := strconv.Itoa(123456) // c = "123456"

// int to int64
// todo

// int64 to string
e := strconv.FormatInt(1234567890123456, 10) // e = "1234567890123456"

// int64 to int
// todo