SyntaxError:扫描三引号的字符串文字时出现EOF(似乎没有任何效果)

时间:2019-04-17 19:00:43

标签: python visual-studio-code syntax-error

我一直在搜索SO大约一个小时,并尝试了所有可能的修复方法。缩进并重新缩进并移动该字符串,计算括号。什么都没有。 我只是在尝试复制发布在here上的代码作为解决方案(因此某些时候它一定对某人有用)。

我不断收到SyntaxError: EOF while scanning triple-quoted string literal错误。

import numpy as np

from bokeh.io import show
from bokeh.layouts import widgetbox
from bokeh.models.widgets import CheckboxGroup
from bokeh.models import CustomJS, ColumnDataSource
from bokeh.layouts import column, row

t = np.arange(0.0, 2.0, 0.01)
s = np.sin(3*np.pi*t)
c = np.cos(3*np.pi*t)

source = ColumnDataSource(data=dict(t=t, s=s, c=c))

plot = figure(plot_width=400, plot_height=400)
a = plot.line('t', 's', source=source, line_width=3, line_alpha=0.6, line_color='blue')
b = plot.line('t', 'c', source=source, line_width=3, line_alpha=0.6, line_color='red')

checkbox = CheckboxGroup(labels=["Cosinus", "Sinus"], active=[0,1])

checkbox.callback = CustomJS(args=dict(line0=a, line1=b), code="""
    //console.log(cb_obj.active);
    line0.visible = false;
    line1.visible = false;
    for (i in cb_obj.active) {
        //console.log(cb_obj.active[i]);
        if (cb_obj.active[i] == 0) {
            line0.visible = true;
        } else if (cb_obj.active[i] == 1) {
            line1.visible = true;
        }
    }
""")

layout = row(plot, widgetbox(checkbox))

show(layout)

enter image description here

1 个答案:

答案 0 :(得分:2)

我是VSCode扩展程序的开发人员。我们在用三引号引起来的字符串时遇到了问题。

https://github.com/Microsoft/vscode-python/issues/5012

此问题的修补程序当前已存在,但仅在我们的开发版本中。要获取此修复程序,您可以等到下周我们每月进行一次扩展发布。或者,如果您愿意,可以选择我们的开发版本,该版本可以立即修复。

https://github.com/Microsoft/vscode-python/blob/master/CONTRIBUTING.md#development-build

如果您安装开发版本,则在发布该版本时,它将自动更新为经过测试的完整版本。

很抱歉给您带来的烦恼。

相关问题