【发布时间】:2020-07-31 16:34:47
【问题描述】:
这似乎是一个非常明显但令人讨厌的问题。 考虑这里的代码块 -
for i in tqdm.notebook.tqdm(range(int(3*len(structures)/4))):
try:
is_mal=np.array([1.]) if 'Malware' in structure_info[i] else np.array([0.])
target=parse_Structure(file=structures[i])
target=np.reshape(target.get_vector(),(-1,1))
is_mal=np.reshape(is_mal,(-1,1))
vectors=np.concatenate((vectors,target), axis=1)
labels=np.concatenate((labels,is_mal), axis=1)
except:
print(i)
无论如何,代码都无关紧要。但我有一个简单的问题。
在我的 Colab Notebook 在线环境中运行此程序时,当我想在循环中间调试某些内容时,我只是尝试中断执行。
这导致打印循环所在的索引,显然中断被视为异常。虽然我同意循环完美执行 try-catch 块这一事实,但我也想严重中断执行。
如何在不重新启动运行时中断此块的执行?
【问题讨论】:
标签: python python-3.x try-catch execution interruption