[Python] Python in VS Code skips reading "[]" plus one more character

Discussão em 'Python' iniciado por Stack, Junho 9, 2025.

  1. Stack

    Stack Membro Participativo

    I have this bizarre problem with using Python in VS Code. Whenever running a command in a .py file that contains [ and ], the program misses both characters plus one more that follows after [.

    So for example the command:

    df = pd.concat([df1,df2], axis = 0)


    is incorrectly read by the program as:

    df = pd.concat(f1, df2, axis=0)


    and therefore an error is reported:

    NameError: name 'f1' is not defined. Did you mean: 'df1'?


    Similarly:

    df["mesic"] = df.added.astype(str).str[0:7]


    is incorrectly read by the program as:

    dfmesic" = df.added.astype(str).str:7


    leading to this error:

    SyntaxError: unterminated string literal (detected at line 1)


    Any ideas on what I can do about it?

    I have reinstalled VS Code and Python but no improvement. Asked various LLM models but they did not advise.

    Continue reading...

Compartilhe esta Página