go语言把int转为字符串的方法:【fmt.Println(strconv.Itoa(100))】。如果要把字符串转为整形,可以使用【i, _ := strconv.Atoi("100") fmt.Println(i)】。

本文操作环境:windows10系统、Go 1.11.2、thinkpad t480电脑。 整形转字符串 fmt.Println(strconv.Itoa(100)) 该方法的源码是: // Itoa is shorthand for FormatInt(i, 10).
func Itoa(i int) string {
return FormatInt(int64(i), 10)
}可以看出是FormatInt方法的简单实现。 字符串转整形 i, _ := strconv.Atoi("100")
fmt.Println(i)相关推荐:golang教程 以上就是go语言如何把int转为字符串的详细内容,更多请关注模板之家(www.mb5.com.cn)其它相关文章! |