selfteaching / selfteaching/selfteaching-python-camp

Day08 关于抛出异常,捕获异常的理解

Open
#655 0 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

学习素材分享
Dominant language
Python
Stars
151
Forks
875
PR merge metrics
No merged PRs in 30d

Description

今天在完成作业时,可能会有基础定义理解上的困扰,在这里贴出来和大家分享。

  1. 抛出异常: 指使用 raise 语句,来触发异常。具体可参考官方文档的8.4部分:
    (中)https://docs.python.org/zh-cn/3/tutorial/errors.html#raising-exceptions
    (英)https://docs.python.org/3/tutorial/errors.html#raising-exceptions
    任务1中,即需要抛出指定异常。

  2. 捕获异常/处理异常:指使用try...except...else语句来建立一个异常处理机制。具体可参考官方文档8.3部分:
    (中)https://docs.python.org/zh-cn/3/tutorial/errors.html#handling-exceptions
    (英)https://docs.python.org/3/tutorial/errors.html#handling-exceptions
    任务3中,即需要捕获并给出异常处理方法。

描述中如有错误的地方,还请大家指正。

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Read the issue's linked Python documentation sections on raising and handling exceptions, along with the references to tasks 1 and 3. Done would mean confirming or correcting the shared explanations, but the issue does not identify a documentation file or a specific change to make.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
documentation
Issue type
Documentation
Difficulty
1/5
Estimated time
Under an hour
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.