【发布时间】:2018-04-10 00:28:52
【问题描述】:
以下代码能够在 Jupyter 笔记本中按预期打印/输出图像:
from IPython.core.interactiveshell import InteractiveShell
InteractiveShell.ast_node_interactivity = "all"
from IPython import display
from scipy.misc import toimage
import numpy as np
n = 3
for _ in range(n):
(toimage(np.random.rand(32, 32, 3)))
print("----------------------------")
但是,一旦我将它放入函数中,它就会停止工作。为什么?我该如何解决?
def print_images(n=3):
for _ in range(n):
(toimage(np.random.rand(32, 32, 3)))
print("----------------------------")
print_images()
【问题讨论】:
标签: image scipy ipython jupyter