Julia:如何导入模块
Julia: how to import a module
我正在使用 Julia 语言,我的 IDE 是 juno。
现在我想导入我自己的模块。这是一个例子:
首先我创建一个模块文件:
module my_module
export test
function test(id, name)
print("Your ID:", id, ". Your name: ", name)
end
end
它的路径是:C:\doc\my_module.jl
现在我想将 my_module.jl
导入到另一个 julia 项目中。这是代码:
import "C:\doc\my_module.jl"
它不起作用,我得到一个错误:
invalid "import" statement: expected identifier
我该怎么办?
要导入模块,您需要include
文件然后导入模块。
查看@Gnimuc Key的评论
还有other ways个模块需要导入。
我正在使用 Julia 语言,我的 IDE 是 juno。
现在我想导入我自己的模块。这是一个例子:
首先我创建一个模块文件:
module my_module
export test
function test(id, name)
print("Your ID:", id, ". Your name: ", name)
end
end
它的路径是:C:\doc\my_module.jl
现在我想将 my_module.jl
导入到另一个 julia 项目中。这是代码:
import "C:\doc\my_module.jl"
它不起作用,我得到一个错误:
invalid "import" statement: expected identifier
我该怎么办?
要导入模块,您需要include
文件然后导入模块。
查看@Gnimuc Key的评论
还有other ways个模块需要导入。