我有一个try语句,大致如下所示。你知道吗
for result in results['matches']:
try:
#runs some functions
except KeyboardInterrupt:
leaveopt = raw_input( 'Would you like to exit or skip the current match? [e/s]:' )
if leaveopt == 'e':
print '\nExiting...'
else:
print '\nSkipping match...'
当我运行程序时,我没有得到任何错误,但当我按下ctrl-c时,它只是跳过当前匹配,而不是询问我想做什么。我想知道是只有一些内容可以在try语句的except部分运行,还是还有其他问题。你知道吗
据我所知,对在
except
中可以做什么没有限制(即使这里有一些您可能希望避免的事情),这对我很有用(python 2.7.3/linux mint):问题显然出在“运行一些函数”部分的某个地方。你知道吗
相关问题 更多 >
编程相关推荐