朱莉娅1.7.2:如何使用@sprintf

发布于 2025-02-07 16:46:30 字数 240 浏览 0 评论 0原文

我是朱莉娅1.7.2的新手。我在Julialang.org上发现了@sprintf。 我尝试将数字45显示为:00045

a = @sprintf "%05i" 45           # I get:  @sprintf not defined

a = Printf.@sprintf "%05i" 45    # I get:  Printf not defined

此1行程序中缺少什么?谢谢

I am new to julia 1.7.2. I found on julialang.org about @sprintf.
I try to show a number 45 as: 00045

a = @sprintf "%05i" 45           # I get:  @sprintf not defined

a = Printf.@sprintf "%05i" 45    # I get:  Printf not defined

What is missing in this 1 line program? Thanks

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

旧竹 2025-02-14 16:46:30

您需要首先导入printf模块。例如,使用使用(在这种情况下,您不需要前缀@sprintf带有printf):

julia> using Printf

julia> @sprintf "%05i" 45
"00045"

You need to import the Printf module first. For example with using (in which case you do not need to prefix @sprintf with Printf):

julia> using Printf

julia> @sprintf "%05i" 45
"00045"
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文