Golang 数据类型转换
文章目录
string To int
字符串为纯数字,值为:123456
aInt, _ := strconv.Atoi("123456") fmt.Printf("数据类型: %T, 值: %d", aInt, aInt)
字符串不为纯数字,值为:0
aInt, _ := strconv.Atoi("123456d") fmt.Printf("数据类型: %T, 值: %d", aInt, aInt)
int To string
纯数字, 值为: 1234
aInt := strconv.Itoa(1234) fmt.Printf("数据类型: %T, 值: %v", aInt, aInt)

评论
登录后参与技术讨论,分享你的经验与见解。
登录 / 注册暂无评论