字符串转int32
package main
import (
"fmt"
"strconv"
)
func main() {
str := "12345"
num, err := strconv.ParseInt(str, 10, 32)
if err != nil {
fmt.Println("转换失败:", err)
return
}
fmt.Printf("%d 的类型是 %T\n", num, num)
// 将 int64 类型转换为 int32 类型
num32 := int32(num)
fmt.Printf("%d 的类型是 %T\n", num32, num32)
}
标签:类型转换,int32,err,fmt,num,Go,num32
From: https://www.cnblogs.com/wangjinkui/p/17136566.html