更新时间:2022-01-05 21:32:28
使用 do
块.关于 do 块的文档在这里.
Use a do
block. Docs on do blocks are here.
下面是一个示例,说明如何在 Julia 中使用 Python 的 open(filename) as my_file 执行通常的 :
And here is an example of how to do the usual with open(filename) as my_file
of Python in Julia:
open("sherlock-holmes.txt") do filehandle
for line in eachline(filehandle)
println(line)
end
end
上面的例子也来自 Julia wikibooks.