δ»ε符串δΈθ§£ζζ°εε¨εΎε€η¨εΊδΈζ―δΈδΈͺεΊη‘εΈΈθ§ηδ»»ε‘οΌ
θε¨ Go δΈοΌζ―θΏζ ·ε€ηηγ
|
|
|

package main
|
ε
ε»Ίη strconv ε
ζδΎδΊζ°εθ§£ζθ½εγ
|
import (
"fmt"
"strconv"
)
|
|
func main() {
|
δ½Ώη¨ ParseFloat οΌθΏιη 64 葨瀺解ζηζ°ηδ½ζ°γ
|
f, _ := strconv.ParseFloat("1.234", 64)
fmt.Println(f)
|
ε¨δ½Ώη¨ ParseInt θ§£ζζ΄εζ°ζΆοΌ
δΎεδΈηεζ° 0 葨瀺θͺε¨ζ¨ζε符串ζ葨瀺ηζ°εηθΏεΆγ
64 葨瀺θΏεηζ΄εζ°ζ―δ»₯ 64 δ½εε¨ηγ
|
i, _ := strconv.ParseInt("123", 0, 64)
fmt.Println(i)
|
ParseInt δΌθͺε¨θ―ε«εΊε符串ζ―εε
θΏεΆζ°γ
|
d, _ := strconv.ParseInt("0x1c8", 0, 64)
fmt.Println(d)
|
ParseUint δΉζ―ε―η¨ηγ
|
u, _ := strconv.ParseUint("789", 0, 64)
fmt.Println(u)
|
Atoi ζ―δΈδΈͺεΊη‘η 10 θΏεΆζ΄εζ°θ½¬ζ’ε½ζ°γ
|
k, _ := strconv.Atoi("135")
fmt.Println(k)
|
ε¨θΎε
₯ιθ――ζΆοΌθ§£ζε½ζ°δΌθΏεδΈδΈͺιθ――γ
|
_, e := strconv.Atoi("wat")
fmt.Println(e)
}
|