VSCode 条件断点(Python)

问题描述 投票:0回答:1

我无法让 VSCode 在 python 项目的简单条件断点处停止。

环境: 操作系统:Windows 10 语言:Python 版本:VSCode 1.87.2

我尝试实现的断点基于

chunk_count
,它是我的代码中基于整数的计数器:

if (chunk_count in (38, 39, 40) 

我也尝试过

if (chunk_count==39)

在循环中的正确时间手动设置断点并在调试器终端上评估这些表达式显示它们评估为

True
那么我做错了什么?

python visual-studio-code ide vscode-debugger
1个回答
0
投票

在 VS 代码中添加条件断点时,它们应该是计算结果为

true
false
的表达式。这仅仅意味着该语句是您在代码中放在 if 语句之后的语句。即

# If this would be in code
if cond:
    breakpoint()
    pass

# This is what you should put in VS code
cond

就您而言,正确的说法是:

chunk_count in (38, 39, 40)
© www.soinside.com 2019 - 2024. All rights reserved.