[英]How to define variable name in Jupyter notebook through interactive widget (python)
I need the following functionality: 我需要以下功能:
#what do you want to name the processed file?
(widget here)
filename=(widget input string)
I did not find any easy examples in the widget documentation or other searches. 我没有在小部件文档或其他搜索中找到任何简单的示例。
You can either use standard python input()
您可以使用标准的python
input()
text = input("Your input: ")
print(text)
or use the ipywidgets
module 或使用
ipywidgets
模块
import ipywidgets as widgets
text = widgets.Text(placeholder='Your input')
display(text)
def print_input(sender):
print(text.value)
text.on_submit(print_input)
also see the docs for the ipywidgets
module here . 也可以在这里查看
ipywidgets
模块的文档。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.