问题描述
我将坐标(位置)作为2个float64数字的输出,它看起来像这样:
& amp ; {%!s(float64 = 42.539679)%!s(float64 = 42.601339)}
我第一次看到类似的东西,那么什么是%!s?
TypeOf表示%!s(float64 = 42.539679)是float64。那么我该如何使用这种浮标呢?有没有什么办法来解析它,或者让%!s(float64 = 42.539679)看起来像42.539679?
UPD:突出显示的行是* tgbotapi。来自Syfaro的电报bot api的位置对象。
api有这样的结构:
$ $ p $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $经度float64`json:longitude `
Latitude float64`json:latitude`
}
和Location.Latitude给了我:%!s(float64 = 42.539679)(float64)(?)
%!s 基本上用于帮助您识别问题。
I'm getting coordinates (location) as an output of 2 float64 numbers, and it looks like this:
&{%!s(float64=42.539679) %!s(float64=42.601339)}
This is the first time I'm seeing anything like that, so what is "%!s"?"TypeOf" says "%!s(float64=42.539679)" is float64. So how do I work with this kind of floats? Is there any way to parse it, or somehow to make the %!s(float64=42.539679) look like 42.539679?
UPD: the highlighted line is a *tgbotapi.Location object from Syfaro's telegram bot api.The api has this structure:
type Location struct {
Longitude float64 `json:"longitude"`
Latitude float64 `json:"latitude"`
}
and the Location.Latitude gives me this: "%!s(float64=42.539679)" (float64)(?)
%!s is basically used in errors to help you identify a problem.
这篇关于什么是“%!s”在浮动的输出?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!