【解决办法】
在每个cell前添加如下代码:
from IPython.core.interactiveshell import InteractiveShell
InteractiveShell.ast_node_interactivity = 'all'
【实例代码】
from IPython.core.interactiveshell import InteractiveShell
InteractiveShell.ast_node_interactivity = 'all'
import numpy as np
np.random.random((3,3))
np.random.normal(0,1,(3,3))
np.random.randint(0,10,(3,3))
输出结果如下:
array([[ 0.87663244, 0.19541597, 0.87798172],
[ 0.59132927, 0.28294794, 0.94359486],
[ 0.96506036, 0.79356566, 0.82647791]])
array([[ 1.11610125, 0.26855448, -1.22159369],
[-0.98259724, -0.04698618, -0.9948715 ],
[-1.1675932 , 0.66727159, -0.80324847]])
array([[1, 6, 3],
[4, 5, 5],
[5, 3, 0]])