似乎无法修复 vscode 中的此错误:“(”未关闭

Cant seem to fix this error in vscode : "(" was not closed

我一直在尝试使用 plotly dash 进行可视化,并想尝试网站文档中的第一个应用程序示例。我复制并粘贴了大部分代码并确保缩进正确,但似乎一直在括号中出现错误。有什么建议吗?

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)

括号没有闭合的地方我已经评论过了。此外,您还缺少 "name" 的值。我也对此发表了评论。 P指括号()C指大括号{}S指方括号[].

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=[          #P1 open, S1 open
    html.H1(children='Hello Dash'),       # P2 open, P2 closed      
    
    html.Div(children='''                   
        Dash: A web application framework for Python.
    '''), # P3 open, P3 closed

    dcc.Graph(                                  #P4 open
        id='example-graph',         
        figure={                                #C1 open
            'data': [                           # S2 open
                {'x': [1, 2, 3], 'y': [4, 1, 2], 'type': 'bar', 'name':# You are missing name parameter here;  Also C2 open; You are not closing this curly braces
                {'x': [1, 2, 3], 'y': [2, 4, 5], 'type': 'bar', 'name':# You are missing name parameter here; Also C3 open; You are not closing this curly braces
            ], #S2 closed

            'layout': {                           #C4 open
                'title': 'Dash Data Visualization'
            }                                     # C4 closed
        } # C1 closed
    ) # P4 closed
])#S1 closed, P1 closed

if __name__ == '__main__':
    app.run_server(debug=True) # this need to be indented