[Go - Basic] 基本变量类型转换

数字转字符串

import "strconv"

  1. int -> string
strconv.Itoa(i int) string
  1. int64 -> string
strconv.FormatInt(i int64, base int) string
base = 10

字符串转数字

import "strconv"

  1. string -> int
strconv.Atoi(s string) (int, error)
  1. string -> int64
strconv.ParseInt(s string, base int, bitSize int) (i int64, err error)
base = 10
bitSize = 64

你可能感兴趣的:(golang)