我想知道是否可以使输出以交互方式运行一段代码。因此,例如,如果我有一个类(伪代码中的部分):
import numpy as np
class test(object):
def __init__():
self.a = np.random.randn(10)
print ## Interactive Output: Click me to view data array##
def show():
print a
因此,当我创建一个类实例时,它应该输出一些交互式链接(可能在 html 中)或类似的东西,当我单击它时,show()
应该调用该方法。但是,我不知道如何实现这一目标。