[英]Python code showing EOF error in Visual Studio Code but works fine in Visual Studio
Just change the indentation for the vscode, it usually if there are trailing spaces.只需更改 vscode 的缩进,通常如果有尾随空格。
You can do that by simply clicking F1 and then type trim trailing whitespace
int the search box and select it.您可以通过简单地单击 F1 然后在搜索框中键入trim trailing whitespace
并选择它来完成此操作。
OR或者CTRL + K
CTRL + X
CTRL + K
CTRL + X
If you still get the same issue try changing indentation to tabs/spaces, follow that same thing as F1 and type indentation
and then select indentation to tabs/spaces as per your convenience.如果您仍然遇到相同的问题,请尝试将缩进更改为制表符/空格,按照与 F1 相同的操作并键入indentation
,然后根据您的方便选择制表符/空格的缩进。
When I used "console": "internalConsole",
(in / .vscode
/ launch.json
) I encountered the same problem.当我使用"console": "internalConsole",
(in / .vscode
/ launch.json
) 我遇到了同样的问题。
The reason is that in this mode, the result will be executed in DEBUG CONSOLE
, and currently this terminal is only used for display output, so the code cannot receive the required input, and an EOF error will be displayed.原因是这种模式下,结果会在DEBUG CONSOLE
执行,目前这个终端只用于显示输出,所以代码无法接收到需要的输入,会显示EOF错误。 (End Of File: There is an unexpected error at the end of the file.) (文件结尾:文件结尾出现意外错误。)
Solution :解决方案:
Use other output methods: "console": "integratedTerminal",
or "console": "externalTerminal",
使用其他输出方法: "console": "integratedTerminal",
或"console": "externalTerminal",
Reference: console in VSCode .参考: VSCode 中的控制台。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.