Syntax Error: "]," invalid syntax - Dash Graph Building
Syntax Error: "]," invalid syntax - Dash Graph Building
我是 Dash 的新手,我必须构建一个 Web 应用程序,在其中打印从麦克风和加速度计读取的一些数据。
现在我正在尝试了解如何设置各种图表和信息。我正在按照 Dash 用户指南中给出的示例进行操作。
错误在第 23 行,即我设置数据和布局的行。他似乎不喜欢 ],但老实说,我不知道该如何解决。
import dash
import dash_core_components as dcc
import dash_html_components as html
external_stylesheets = ['https://codepen.io/chriddyp/pen/bWLwgP.css']
app = dash.Dash(__name__,external_stylesheets=external_stylesheets)
app.layout = html.Div(children=[
html.H1(children='Hello Dash'),
html.Div(children='''Dash: A web application framework for Python.'''),
dcc.Graph(id='example-graph',
figure={
'data': [
{'x': [1, 2, 3], 'y': [4, 1, 2], 'type': 'bar', 'name':
{'x': [1, 2, 3], 'y': [2, 4, 5], 'type': 'bar', 'name':
],
'layout': {
'title': 'Dash Data Visualization'
}
}
)
])
if __name__ == '__main__':
app.run_server(debug=True)
- 语法错误:
文件 "app.py",第 23 行
],
^
语法错误:语法无效
为什么会出现这种错误?
P.s.: 用户指南(第一个例子)-> https://dash.plot.ly/getting-started
试试这个:
import dash
import dash_core_components as dcc
import dash_html_components as html
external_stylesheets = ['https://codepen.io/chriddyp/pen/bWLwgP.css']
app = dash.Dash(__name__,external_stylesheets=external_stylesheets)
app.layout = html.Div(children=[
html.H1(children='Hello Dash'),
html.Div(children='''Dash: A web application framework for Python.'''),
dcc.Graph(id='example-graph',
figure={
'data': [
{'x': [1, 2, 3], 'y': [4, 1, 2], 'type': 'bar', 'name':'a'},
{'x': [1, 2, 3], 'y': [2, 4, 5], 'type': 'bar', 'name':'b'}
],
'layout': {
'title': 'Dash Data Visualization'
}
}
)
])
if __name__ == '__main__':
app.run_server(debug=True)
输出
Running on http://127.0.0.1:8050/
Debugger PIN: 201-392-957
* Serving Flask app "main" (lazy loading)
* Environment: production
WARNING: This is a development server. Do not use it in a production deployment.
Use a production WSGI server instead.
* Debug mode: on
Running on http://127.0.0.1:8050/
Debugger PIN: 906-971-228
我是 Dash 的新手,我必须构建一个 Web 应用程序,在其中打印从麦克风和加速度计读取的一些数据。
现在我正在尝试了解如何设置各种图表和信息。我正在按照 Dash 用户指南中给出的示例进行操作。
错误在第 23 行,即我设置数据和布局的行。他似乎不喜欢 ],但老实说,我不知道该如何解决。
import dash
import dash_core_components as dcc
import dash_html_components as html
external_stylesheets = ['https://codepen.io/chriddyp/pen/bWLwgP.css']
app = dash.Dash(__name__,external_stylesheets=external_stylesheets)
app.layout = html.Div(children=[
html.H1(children='Hello Dash'),
html.Div(children='''Dash: A web application framework for Python.'''),
dcc.Graph(id='example-graph',
figure={
'data': [
{'x': [1, 2, 3], 'y': [4, 1, 2], 'type': 'bar', 'name':
{'x': [1, 2, 3], 'y': [2, 4, 5], 'type': 'bar', 'name':
],
'layout': {
'title': 'Dash Data Visualization'
}
}
)
])
if __name__ == '__main__':
app.run_server(debug=True)
- 语法错误: 文件 "app.py",第 23 行 ], ^ 语法错误:语法无效
为什么会出现这种错误?
P.s.: 用户指南(第一个例子)-> https://dash.plot.ly/getting-started
试试这个:
import dash
import dash_core_components as dcc
import dash_html_components as html
external_stylesheets = ['https://codepen.io/chriddyp/pen/bWLwgP.css']
app = dash.Dash(__name__,external_stylesheets=external_stylesheets)
app.layout = html.Div(children=[
html.H1(children='Hello Dash'),
html.Div(children='''Dash: A web application framework for Python.'''),
dcc.Graph(id='example-graph',
figure={
'data': [
{'x': [1, 2, 3], 'y': [4, 1, 2], 'type': 'bar', 'name':'a'},
{'x': [1, 2, 3], 'y': [2, 4, 5], 'type': 'bar', 'name':'b'}
],
'layout': {
'title': 'Dash Data Visualization'
}
}
)
])
if __name__ == '__main__':
app.run_server(debug=True)
输出
Running on http://127.0.0.1:8050/
Debugger PIN: 201-392-957
* Serving Flask app "main" (lazy loading)
* Environment: production
WARNING: This is a development server. Do not use it in a production deployment.
Use a production WSGI server instead.
* Debug mode: on
Running on http://127.0.0.1:8050/
Debugger PIN: 906-971-228