나는 특히 마지막 블록을 제외 관한 호기심 질문,이 : 첫 번째에서 minimaly 다른 인이 작동하도록되어 마지막으로 초 사이에, 작동마지막으로 제외 운영자
코드의 첫 번째 블록 동안 그것을 항상 오류가 발생합니다.
먼저 :
def askint():
while True:
try:
val = int(raw_input("Please enter an integer: "))
except:
print "Looks like you did not enter an integer!"
continue
else:
print 'Yep thats an integer!'
break
finally:
print "Finally, I executed!"
print val
둘째 :
def Abra():
while True:
try:
v = int(raw_input('Geben Sie bitte einen Integer ein (1-9) : '))
except :
print 'Einen Integer bitte (1-9)'
continue
if v not in range(1,10):
print ' Einen Integer von 1-9'
continue
else:
print 'Gut gemacht'
break
finally:
print "Finally, I executed!"
아브라() 모든 솔루션을위한
열기 - 감사
동일한 들여 쓰기 수준에서 'if'는 'try'제어 구조를 끝냅니다. '마침내'는 그와 관련이 없습니다. –
두 번째 코드 블록에서'finally'는'except' 블록 다음에 없습니다. 그것은 구문 오류입니다 ... – GPhilo