Python:Canopy>>工作区窗口在哪里?

2024-04-24 05:50:26 发布

您现在位置:Python中文网/ 问答频道 /正文

我使用名为Canopy的接口来编写Python代码。 我是新手,花了好几个小时才找到工作区窗口(就像Matlab的工作区,程序员可以通过导航找到创建的变量)

任何帮助我们都将不胜感激。 提前致谢!enter image description here


Tags: 代码程序员小时matlab新手canopy
2条回答

Canopy1.5将于10月份发布,它将包含一个GUI调试器,该调试器提供名称空间/变量的显示/浏览(以及诸如断点、单步执行代码等调试功能)。在

唉,天棚里现在还没有这样的窗格。向他们发送反馈请求(帮助->反馈/错误),他们可能会在将来将其包括在内。有两种选择:

1)可以使用PyCharm这样的程序,它有一个工作区窗口。在

2)您可以生成自己的“工作区”功能:

# First note the variables present before we make any.  Only variables made after this line are part of the "workspace"
locvars = locals().copy()

# Print out an list of variables that aren't python internal.  We will call the workspace the collection
# of variables which were made after the first instruction executed.
# This function expects the calling namespace to have a variable locvars which is a copy of locals taken before
# any variables were made for inclusion into the "workspace".
def showlocals():
    # Get the calling frame's locals
    import inspect
    locs = inspect.currentframe().f_back.f_locals
    locvars = locs['locvars']

    # Get the list of variables in the workspace.
    workspace = [k for (k, v) in locs.items() if k not in locvars.keys() and k[0] != '_' and k != 'locvars' and k != 'showlocals']

    # Print out the names and values of those.
    for (k,v) in locs.items():
        if k in workspace:
            print '%s = %s' % (k, v)

# Now you do your code which produces variables.
x = 5
y = 7

# Everytime you want to print out the variables you call this function.
showlocals()

得到如下输出:

^{pr2}$

相关问题 更多 >