📜  在 python 代码示例中尝试和除外

📅  最后修改于: 2022-03-11 14:46:46.781000             🧑  作者: Mango

代码示例6
# Try and Except in python are for taking care of errors
# which may occur at runtime.
# For example:

# If flask is not installed, you will get an ImportError saying flask
# is not installed.
# The try keyword is to try running that block of code which may cause an error.
try:
    from flask import Flask
except ImportError:
    print('Flask is not installed! Use pip install flask to install it.')