Ser*_*lla 5 go
现在我正在执行以下操作以解析字符串中的整数,然后将其转换为int类型:
int
tmpValue, _ := strconv.ParseInt(str, 10, 64) //returns int64 finalValue = int(tmpValue)
它非常冗长,并且绝对不是很漂亮,因为我还没有找到一种方法来在ParseInt电话中进行转换.有没有更好的方法呢?
ParseInt
Fre*_*Foo 5
看起来这个函数strconv.Atoi做了你想要的,除了它的工作原理无论位大小int(你的代码似乎假设它是64位宽).
strconv.Atoi
归档时间:
13 年,5 月 前
查看次数:
147 次
最近记录: