我的调试器甚至没有开始运行我的代码。我按F5,调试选项卡打开,显示正在加载,一段时间后在弹出窗口中显示“会话-1超时等待被调试程序生成”。我使用的是VS Code版本1.40.1,我已经设置了我的虚拟环境,并且调试器可以正常工作,在断点处停止并更改屏幕底部蓝色条的颜色。在处理open()函数时出现问题,但调试器不能处理任何文件。我已经看到并尝试了here和here提供的解决方案。除了标准的Python扩展外,我不使用Conda、Jupyter或任何扩展。代码:
import os
def fib(n):
if not os.path.exists("Fibfile.txt"):
with open("Fibfile.txt", "w") as file:
file.write("1\n2\n")
with open("Fibfile.txt", "r") as file:
contents = file.readlines()
data = []
for item in contents:
# removes newline
data.append(int(item[:-1]))
with open("Fibfile.txt", "a") as file:
if n <= len(data):
return
else:
while n > len(data):
data.append(data[-2]+data[-1])
file.write(f"{data[-1]}\n")
fib(100)
我的launch.json:
{
// 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: Arquivo Atual",
"type": "python",
"request": "launch",
"program": "${file}",
"console": "integratedTerminal"
}
]
}
发布于 2019-12-02 12:24:04
我的解决方案是降级Python extension for Visual Studio Code。您可以从GitHub release下载。PTVSD版本2019.10.44104适用于VS Code 1.40.2。未选中的扩展:自动更新/自动检查更新,并从VSIX手动安装。
更新:更新版本VS Code 1.41已经解决了这个问题。
https://stackoverflow.com/questions/59012582
复制相似问题