I'm trying to understand one of the answers to this question:
Cannot pass an argument to python with "#!/usr/bin/env python"
#!/bin/sh
''''exec python -u -- "$0" ${1+"$@"} # '''
Run Code Online (Sandbox Code Playgroud)
This works well, but I do not understand why it works with four ticks at the beginning of that line rather than three.
In addition, why the hash near the end of that string?
是否可以编写一个Jupyter笔记本,以便参数可以通过笔记本的URL传入?
例如,对于这样的URL:
http://jupyter.example.com/user/me/notebooks/notebook1.ipynb?Variable1=Value1&Variable2=Value2
Run Code Online (Sandbox Code Playgroud)
如何可以访问Variable1,并Variable2在Jupyter细胞内?
据我所知,从这个github页面,我可以将.ipynb推送到我的仓库,然后直接从github运行我的笔记本.
当我让我的Jupyter将我的笔记本下载为.ipynb时,我得到了一个.ipynb.json.
我必须对该文件做什么才能让github为我打开带有nbviewer的笔记本?
据我了解,我应该能够foo在下面的代码段中打印变量.
from IPython.display import HTML
HTML('''
<script type="text/javascript">
IPython.notebook.kernel.execute("foo=97")
</script>
''')
print(foo)
Run Code Online (Sandbox Code Playgroud)
相反,我看到此错误消息:
NameErrorTraceback (most recent call last)
<ipython-input-2-91b73ee49ec6> in <module>()
5 </script>
6 ''')
----> 7 print(foo)
NameError: name 'foo' is not defined
Run Code Online (Sandbox Code Playgroud)
我正在尝试使用这个答案,但努力使其成功.
FWIW,这是在Fedora 23上运行的最新Jupyter代码(根据pip).使这项工作的先决条件是什么?
$ cat foo.libsonnet
{
local foo = 99,
bar: [ foo, 101 ]
}
$ cat baz.jsonnet
{
local foo = import 'foo.libsonnet',
baz: [foo.foo, foo.bar]
}
$ jsonnet baz.jsonnet
RUNTIME ERROR: field does not exist: foo
baz.jsonnet:3:11-18 thunk <array_element>
baz.jsonnet:3:10-28 object <anonymous>
During manifestation
Run Code Online (Sandbox Code Playgroud)
在这个例子中,很容易访问bar的字段foo。有什么办法可以baz.jsonnet访问当地人吗foo.libsonnet?
如果答案是否定的,我应该如何实现foo,baz以便我可以访问in Both和 also in 的foo字段?foo.libsonnetfoo.libsonnetbaz.jsonnet