golang.org 的官方 fmt pacakge 文档在指定宽度和精度方面这样说 -
Either or both of the flags may be replaced with the character '*', causing their values to be obtained from the next operand, which must be of type int.
星号 (*) 将如何使用,例如,在以下场景中 -
var f float32 = 12.3456789
fmt.Printf("%6.3f", f)
最佳答案
应该是
var f float32 = 12.3456789
fmt.Printf("%*.*f", 20, 1, f)
查看更多:
关于go - 在 Go 中使用星号 (*) 指定宽度和精度,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47707234/