Ale*_*lex 3 type-conversion go
处理resp.Body格式化[]uint8而不是JSON 格式的http的最佳方法是什么?我想将字节转换为a float64.
这是返回值响应:
value : %!F([]uint8=[48 46 48 48 49 50 53 53 50 49])
Run Code Online (Sandbox Code Playgroud)
尝试使用ParseFloat从strconv包(播放):
b := []uint8{48, 46, 48, 48, 49, 50, 53, 53, 50, 49}
f, err := strconv.ParseFloat(string(b), 64)
if err != nil {
// Handle parse error
}
fmt.Printf("%f\n", f) // 0.001255
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
214 次 |
| 最近记录: |