【发布时间】:2020-10-24 16:27:18
【问题描述】:
我正在尝试在 microsoft 可视化代码中运行一个简单的 python 程序,但是,当我运行调试器时,我收到错误 ImportError: can't find 'main'。如果我在终端中运行代码,它可以正常工作。这个问题在我创建的每个程序中都存在。调试器前一天工作正常,但现在没有我改变任何东西,它就不再工作了。我试过重新安装vs code,但没有效果。有人可以解释我需要做什么吗?
下面是我使用的代码。
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"
}
]
}
【问题讨论】:
-
你能分享你的launch.json文件吗
-
这主要是由于一些配置错误而发生的。我会说请访问stackoverflow.com/questions/46520127/…。
标签: python visual-studio-code main