在IPython工作时,我输入了3个作业:
In [1]: foo = 1
In [2]: bar = 2
In [3]: zoo = 3
我打算把他们的口述拿来。你知道吗
In [4]: globals()
Out[4]:
{...
'bar': 2,
'exit': <IPython.core.autocall.ExitAutocall at 0x10e61b048>,
'foo': 1,
'get_ipython': <bound method InteractiveShell.get_ipython of <IPython.terminal.interactiveshell.TerminalInteractiveShell object at 0x10e617208>>,
'quit': <IPython.core.autocall.ExitAutocall at 0x10e61b048>,
'zoo': 3}
globals
按字母顺序打印dict,因此我不能用一个操作选择所有dict。你知道吗
如何从globals()以assignent\u创建的顺序获取dict?你知道吗
首先,globals不跟踪创建顺序。 其次,您可以尝试删除不需要的项,然后对字典进行排序,如下所示:
相关问题 更多 >
编程相关推荐