本文主要是介绍【Dash】开始学习dash,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
安装Dash
网上很多安装dash的教程,不再赘述
开始Dash
一个dash页面的基本写法
# dash 的基本写法
import dash
from dash import html,dcc,callback,Input,Output# 创建一个 dash 应用
app = dash.Dash()# 定义布局,定义一个输入框和一个输出框
app.layout = html.Div([dcc.Input(id='my-input', value='initial value', type='text'),html.Div(id='my-output')
])# 定义回调函数,将输入框的值作为输出显示
@callback(# 定义输出组件Output(component_id='my-output', component_property='children'),# 定义输入组件Input(component_id='my-input', component_property='value')
)
# 定义回调函数的具体实现
def update_output_div(input_value):# 返回输出内容return 'You\'ve entered "{}"'.format(input_value)if __name__ == '__main__':app.run_server(debug=True) # debug=True 开启热更新,修改代码后会自动更新
这篇关于【Dash】开始学习dash的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!