主页

Go strconv.Itoa函数(将int转换为string)

2023-04-04 03:48PM

概念:

strconv.Itoa函数用于将int数字转换为字符串

函数签名

funcItoa(i int)string

返回值:strconv.Itoa函数参数整型数字对应的数字字符串

代码实例:

package main
import "fmt"
import "strconv"
func main() {
    result := strconv.Itoa(23)
    fmt.Println(result)
    // 输出结果为: 23
}

Itoa函数

strconv.Itoa函数的参数是一个整型数字,它可以将数字转换成对应的字符串类型的数字

package main
 
import (
    "fmt"
    "strconv"
)
 
func main() {
    string_number := 97
    result := strconv.Itoa(string_number)
 
    fmt.Println(result)
    fmt.Printf("%T\n", result)
}
//输出结果
//97
//string

参考:https://blog.csdn.net/TCatTime/article/details/120108417

返回>>

登录

请登录后再发表评论。

评论列表:

目前还没有人发表评论