首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >无法修复vscode中的错误:"(“未关闭”)。

无法修复vscode中的错误:"(“未关闭”)。
EN

Stack Overflow用户
提问于 2022-03-26 08:30:20
回答 1查看 902关注 0票数 -1

我一直试图用巧妙的破折号进行可视化,并希望尝试第一个应用程序的例子,从网站文档。我复制并粘贴了大部分代码,并确保了正确的缩进,但似乎始终在括号中出现错误。有什么建议吗?

代码语言:javascript
运行
复制
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)
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2022-03-26 09:02:43

我已就括号没有关闭的地方发表意见。另外,您还缺少了"name"的值。我也对此发表了意见。P指括号()C指圆括号{}S指方括号[]

代码语言:javascript
运行
复制
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
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/71626452

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档