Julia 中的语法是否与 Python 中的语法相同:print(f"{ }")? [重复]

问题描述 投票:0回答:1

在 Python 中,我们有语法:

print(f"This is a number {1}")

在 Julia 中,是否有类似的语法或类似的方法来做到这一点?

syntax julia
1个回答
0
投票

字符串插值是在 Julia 中使用

$(...)
完成的,请参阅 documentation。例子:

julia> x = 1; y = "world";

julia> str = "x is $(x) and y is $(y)"
"x is 1 and y is world"
© www.soinside.com 2019 - 2024. All rights reserved.