首页/作品列表/编辑器代码表单(测试版)使用说明
编辑器代码表单(测试版)使用说明
4481 1
主要内容
表单提供了参数化代码的简单方法。当您更改表单中的值时,代码中相应的值将更改。反之亦然。
#@title 表示表单标题
#@param 表示启用表单
表单只能应用在赋值操作上

下面是几个例子:

#@title 字符串表单

text = 'value' #@param {type:"string"}
dropdown = '1st option' #@param ["1st option", "2nd option", "3rd option"]
text_and_dropdown = '2nd option' #@param ["1st option", "2nd option", "3rd option"] {allow-input: true}

print(text)
print(dropdown)
print(text_and_dropdown)
#@title 自定义输入,输入的值不会做类型转换

raw_input = None #@param {type:"raw"}
raw_dropdown = 1 #@param [1, "raw_input", "False", "'string'"] {type:"raw"}

print(raw_input)
print(raw_dropdown)
#@title 时间表单
date_input = '2018-03-22' #@param {type:"date"}

print(date_input)
#@title 数值表单
number_input = 10.0 #@param {type:"number"}
number_slider = 0.4 #@param {type:"slider", min:-1, max:1, step:0.1}

integer_input = 10 #@param {type:"integer"}
integer_slider = 12 #@param {type:"slider", min:0, max:100, step:1}

print(number_input)
print(number_slider)

print(integer_input)
print(integer_slider)
#@title 布尔表单
boolean_checkbox = True #@param {type:"boolean"}
boolean_dropdown = True #@param ["False", "True"] {type:"raw"}

print(boolean_checkbox)
print(boolean_dropdown)

所需硬件
暂无数据!
代码展示
暂无数据!
附件下载
暂无数据!
1

问天鼓

和 Google 的 Colab 同步 👍

回复0

大牛,别默默的看了,快登录帮我点评一下吧!

立即注册