FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
programmingWithPythonCode/syntax/try_except.py at main · thomasWeise/programmingWithPythonCode · GitHub
thomasWeise
programmingWithPythonCode
Repository navigation
Code
Issues
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
programmingWithPythonCode
/
syntax
/
try_except.py
Copy path
More file actions
More file actions
Latest commit
History
History
History
16 lines (14 loc) · 775 Bytes
Breadcrumbs
programmingWithPythonCode
/
syntax
/
try_except.py
Copy path
File metadata and controls
16 lines (14 loc) · 775 Bytes
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
"""The syntax of a try-except statement in Python."""
try
:
# Begin the try-except block.
statement
1
# Code that may raise an exception or that
statement
2
# calls a function that may rise one.
# ...
except
ExceptionType1
as
ex1
:
# One exception type that can be caught.
statements
processing
ex1
# Code the handles exceptions of type ExceptionType1.
except
ExceptionType2
:
# Another exception type (optional).
statements
processing
exceptions
of
type
ExceptionType2
# Code the handles exceptions of type ExceptionType2 that are not
# instances of ExceptionType1. Notice that we do not necessarily
# need to store the exceptions in variables with, like "as ex2".
next
statement
# Executed only if there are no uncaught Exceptions.
Back
|
FazBrowse Home
|
New Git URL