mirror of
https://gitee.com/shikong-sk/golang-study
synced 2025-02-23 23:42:15 +08:00
25 lines
387 B
Go
25 lines
387 B
Go
package main
|
|
|
|
import (
|
|
"fmt"
|
|
"strconv"
|
|
)
|
|
|
|
func main() {
|
|
str := "10000"
|
|
fmt.Printf("%T %#v\n", str, str)
|
|
|
|
// 字符串转 int64
|
|
i, _ := strconv.ParseInt(str, 10, 64)
|
|
fmt.Printf("%T %#v\n", i, i)
|
|
|
|
// int 转 字符串
|
|
str = strconv.Itoa(int(i))
|
|
fmt.Printf("%T %#v\n", str, str)
|
|
|
|
// 字符串转 bool
|
|
str = "true"
|
|
b, _ := strconv.ParseBool(str)
|
|
fmt.Printf("%T %#v\n", b, b)
|
|
}
|