打电话给IPython 5.x魔术' whos'来自Python2脚本

时间:2017-07-10 13:16:00

标签: python ipython workspace

我想展示我的ndarray变量" workspace"当有异常时,我做了以下代码:

import sys
import numpy as np
try :
    a1 = np.random.random_integers(5, size=(3,2))
    functionThatProvokesAnException(*arguments)
except Exception as why :
    print("=> ERROR: %s" % why,file=sys.stderr)
    from IPython import get_ipython
    ipython = get_ipython()
    ipython.magic("whos ndarray")
    sys.exit(-2)

但它说: AttributeError: 'NoneType' object has no attribute 'magic'

你能帮忙吗?

0 个答案:

没有答案