16

Go语言int显性转string类型

 3 years ago
source link: https://studygolang.com/articles/32192
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

Go语言int显性转string类型

折老爷 · 大约12小时之前 · 75 次点击 · 预计阅读时间不到 1 分钟 · 不到1分钟之前 开始浏览    

如果想要转换数据类型,需要用到go语言strconv package,所有的类型转换都包含在这个库里

package main

import "fmt"
import "strconv" //引入strconv

func main(){
    //声明变量格式var identifier type
    var a int = 10
    b := strconv.Itoa(a)//使用Itoa方法转换
    fmt.Println("转换后:" + b)//输出a
}
4eed32bf9c5236bc3dc5c8da088a6e58.png

有疑问加站长微信联系(非本文作者)

280

入群交流(和以上内容无关):加入Go大咖交流群,或添加微信:liuxiaoyan-s 备注:入群;或加QQ群:1006366459


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK