使用案例
fileName := "url_data_" + strconv.FormatUint(i, 10) + ".txt"
返回结果
url_data_1.txt
url_data_2.txt
…
strconv.FormatUint(i,10)函数的两个参数是什么意思?
直接看Go库源码
// FormatUint returns the string representation of i in the given base,
// for 2 <= base <= 36. The result uses the lower-case letters 'a' to 'z'
// for digit values >= 10.
func FormatUint(i uint64, base int) string {
if fastSmalls && i < nSmalls && base == 10 {
return small(int(i))
}
_, s := formatBits(nil, i, base, false, false)
return s
}
解读:
strconv.FormatInt(i int64,base int)string
返回 i 的 base进制的字符串表示。
base必须在2-36之间