【发布时间】:2013-08-09 15:05:43
【问题描述】:
这是一个测试用例。
try:
targ = raw_input("Please enter target: ")
except KeyboardInterrupt:
print "Cancelled"
print targ
当我按ctrl+c-时我的输出如下
NameError: name 'targ' is not defined
我的意图是“取消”输出。当我尝试在 raw_input 期间捕获 KeyboardInterrupt 时,有什么想法会发生这种情况吗?
谢谢!
【问题讨论】: