我觉得很难用Julia格式化数字:
b = 1.111111
bb = @printf "test : %5.2f" b
bb
test : 1.11
Run Code Online (Sandbox Code Playgroud)
那样就好.
using PyPlot
annotate(@printf "test : %5.2f" b, xy=[1;1])
test :
type: non-boolean (Array{Bool,1}) used in boolean context
while loading In[16], in expression starting on line 2
Run Code Online (Sandbox Code Playgroud)
我不明白,因为我希望@printf的结果是一个String.所以,如果有人可以解释我应该怎么做
"test : %5.2f" % b
Run Code Online (Sandbox Code Playgroud)
在Python中.
总而言之,这是奇怪的事情:
b
1
Run Code Online (Sandbox Code Playgroud)
b已投射到Int.你会称那个错误吗?
我使用Julia 0.3.2和Jupyter 3.1
julia ×1