在Julia Lang中获取当前变量的列表 [英] Get a list of current variables in 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屋!