ImportError: can't find '__main__'

ImportError: can't find '__main__'

我正在尝试 运行 一个简单的 python 微软可视代码程序,但是,当我 运行 调试器时,我收到错误 ImportError: can't find '主要'。如果我在终端中 运行 代码工作正常。这个问题在我创建的每个程序中都存在。前一天调试器运行良好,但现在如果我不做任何更改,它就不再工作了。我试过重新安装vs代码,但没有效果。有人可以解释我需要做什么吗?

下面是我使用的代码。

t = []
for x in range(0,5):
    t.append(["x"] *5)


def review(t):
    for row in t:
        print("".join(row))
review(t)

这是我的启动文件

{
    // Use IntelliSense to learn about possible attributes.
    // Hover to view descriptions of existing attributes.
    // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
    "version": "0.2.0",
    "configurations": [
        
        {
            "name": "Python: Current File ",
            "type": "python",
            "request": "launch",
            "program": "${workspaceFolder}",
            "console": "integratedTerminal"
        }
    ]
}

program值处的问题,应该是"${file}"而不是"${workspaceFolder}"

{
    // Use IntelliSense to learn about possible attributes.
    // Hover to view descriptions of existing attributes.
    // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
    "version": "0.2.0",
    "configurations": [
        
        {
            "name": "Python: Current File ",
            "type": "python",
            "request": "launch",
            "program": "${file}", // new here
            "console": "integratedTerminal"
        }
    ]
}

现在应该可以使用了