How to save an NxNxN array (or Matrix) into a file in Julia (or Python)?

前端 未结 2 1005
天命终不由人
天命终不由人 2021-02-13 00:42

I\'m working on a Jupyter notebook and currently using Julia

I\'m trying to save a 3x3x3 Array into a textfile so when I include it in another notebook, the array is a 3

2条回答
  •  时光说笑
    2021-02-13 01:13

    You could use the JLD.jl (Julia Data) package:

    Pkg.add("JLD")
    using JLD
    r = rand(3, 3, 3)
    save("data.jld", "data", r)
    load("data.jld")["data"]
    

    The advantage of the JLD package is that it preserves the exact type information of each variable.

提交回复
热议问题