Go语言的字符串和数字的相互转换


Go语言strconv库的Atoi:

字符串转数字

package main

import (
    "fmt"
    "strconv"
)

func main() {
    s := "100"
    s1, _ := strconv.Atoi(s)
    fmt.Println(s1)
}

Go语言strconv库的Itoa:

数字转字符串

package main

import (
    "fmt"
    "strconv"
)

func main() {
    x := 200
    s :=strconv.Itoa(x)
    fmt.Println(s)
}


原文链接:https://blog.csdn.net/qq_42410605/article/details/112677904