码迷,mamicode.com
首页 > 其他好文 > 详细

golang 字符串与int类型转换

时间:2018-09-21 19:00:45      阅读:364      评论:0      收藏:0      [点我收藏+]

标签:lang   term   water   process   ges   .com   document   类型   src   

一、字符串转int
func Atoi(s string) (int, error)

案例:
技术分享图片
执行结果:
sf@SFdeMacBook-Pro  ~/Documents/project/src/test  go build int_string.go
sf@SFdeMacBook-Pro  ~/Documents/project/src/test  ./int_string
int, 100

二、int转字符串
func Itoa(i int) string

技术分享图片

执行结果:
sf@SFdeMacBook-Pro  ~/Documents/project/src/test  go build int_string.go
sf@SFdeMacBook-Pro  ~/Documents/project/src/test  ./int_string
string,100

golang 字符串与int类型转换

标签:lang   term   water   process   ges   .com   document   类型   src   

原文地址:http://blog.51cto.com/jiekeyang/2178626

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!