如何将数组作为参数从 Ipython 笔记本传递到包含一些 javascript 函数的 html 文件?

How do I pass an array as parameter from Ipython notebook to an html file, which contains some javascript functions?

我有一个 html 文件 (file.html),其中包含一个 javascript 函数,如下所示:

file.html

<html>
 <head> 
 </head>
<script>
    function demo()
    {
       do something using param1;
    }
</script>
</html>

'Param1' 是我每次调用 file.html 时需要从 IPython 笔记本传递的数组。要求是在我使用以下命令所做的笔记本本身中显示 file.html 的输出。

from IPython.display import IFrame
IFrame('file.html', width=1000, height=550)

您可能希望将数组作为 URL 参数传递。

假设您的数组是 {'a', 'b', 'c', 'd'} - 您可以执行 IFrame('file.html?param1=a,b,c,d', width=1000, height=550),然后从 javascript 获取 url 个参数。如何将数组格式化为文本字符串取决于您。

关于获取 url 参数:javascript but here is an implementation.

中没有标准方法

然后在 demo().

里面用它 need/want 做任何事