0
Can anybody explain what a raise exception is and what is the difference between it and try....except?
raise exception in python
3 odpowiedzi
+ 7
There was a thread about it just very recently, check it out:
https://www.sololearn.com/discuss/758398/?ref=app
+ 1
I haven't really touched Python so far but raise exception might be what essentially "throws" or raises the exception (creates one).
Try is probably which handles (catches) the raised exceptions in its scope.
+ 1
try:
command1
except:
command 2
if the command you write under try is an error:
it will execute command under except.
raise will make your program error
print("hello world")
raise KeyboardIntetrupt
will causing error