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

查看:115
本文介绍了在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天全站免登陆