获取 Julia Lang 中的当前变量列表 [英] Get a list of current variables in Julia Lang

查看:11
本文介绍了获取 Julia Lang 中的当前变量列表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是 Julia Lang 的新手.我来自 Matlab 的背景.

I am new to Julia Lang. I am coming from the background of Matlab.

在 Matlab 中,当按下 whos 命令时,我将获取当前范围内的所有变量;而且,我可以将它们存储在另一个变量中,例如 x=whos; Julia 中是否存在这样的命令?Matlab中的示例代码:

In Matlab, when pressing whos command I will get all variables in the current scope; and also, I can store them in another variable like x=whos; Is there such commands exists in Julia? Example code in Matlab:

>> a=3;
>> b=4;
>> whos
Variables in the current scope:

Attr Name        Size                     Bytes  Class
==== ====        ====                     =====  ===== 
    a            1x1                          8  double
    b            1x1                          8  double
    prefix       1x16                        16  char

Total is 18 elements using 32 bytes.

推荐答案

不知道有没有更好的,但是

Not sure if there is something better, but

names(Main)[4:end]

似乎有效.[4:end] 部分是因为它包括我认为的 :Main:Core:Base你不会想要的.我希望他们永远都在开始.

seems to work. The [4:end] part is because it includes :Main, :Core and :Base which I think you would not want. I hope they will always be at the beginning.

这篇关于获取 Julia Lang 中的当前变量列表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆