如何在 IRuby + Jupyter 中输入字符串?

How to input a string in IRuby + Jupyter?

我在 Jupyter 上使用 iruby。在 python 内核 (ipython) 中,可以通过调用 input() 函数从笔记本输入一个字符串。

是否可以在iruby中实现同样的功能?

如果您使用 Jupyter Notebook, 尝试 IRuby.input

https://github.com/SciRuby/iruby/tree/master/lib/iruby/input

但是这个输入框在 Jupyter Lab 中可能不起作用。

简单的文本输入使用 IRuby.input:

name = IRuby.input 'Enter your name'

多字段输入完成 IRuby.form:

result = IRuby.form do 
  input :username
  button
end

它returns一个以输入字段名称作为标签的哈希。