다음 함수에서 try:
을 일찍 끝내고 있습니까? def
블록 외부에 동일한 코드를 넣으면 제대로 작동합니다.무엇을 만들고 있습니까? 일찍 종료 하시겠습니까?
tiles = ['095D', '094M']
in_file = 'in_file'
out_file = 'out_file'
expression = ''' "FIELDNAME" LIKE 'STUFF' '''
def foobar(in_file, out_file, expression):
print in_file, out_file, expression
try:
print 'this is trying'
#pretty print tile list, from http://stackoverflow.com/questions/2399112/python-print-delimited-list
tiles = ','.join(map(str,tiles))
print 'made it past tiles!'
print 'From %s \nselecting %s \ninto %s' % (in_file, tiles, out_file)
except:
print 'Made it to the except block!'
foobar(in_file, out_file, expression)
결과 : same code not in a def와
D:\> python xx-debug.py
in_file out_file "FIELDNAME" LIKE 'STUFF'
this is trying
Made it to the except block!
결과 :
당신은 흥미로운 버그this is trying
made it past tiles!
From in_file
selecting 095D,094M
into out_file
등이 있으며, 초보자도 그렇게 할 것입니다. –
@aaronasterling "포켓몬 예외 처리 - 모두 잡아 야해!" –
예외를 지정하지 않고'except :'하지 않아야합니다. 그러면 KeyboardInterrupt 같은 것을 잡을 것입니다. KeyboardInterrupt는 거의 당신이 원하는 것이 아닙니다. – ThiefMaster