Explore Enterprise Education Gitee Premium Gitee AI AI teammates
Fetch the repository succeeded.
Donate
Please sign in before you donate.
Scan WeChat QR to Pay
Cancel
Complete
Prompt
Switch to Alipay.
OK
Cancel
1 Star 0 Fork 1

aliao/stdpython

forked from pish7/stdpython
Create your Gitee Account
Explore and code with more than 14 million developers,Free private repositories !:)
Sign up
Already have an account? Sign in
文件
master
Branches (1)
master
This repository doesn't specify license. Please pay attention to the specific project description and its upstream code dependency when using it.
The license selected for the repository is subject to the license used by the main branch of the repository.
master
Branches (1)
master
Clone or Download
Clone/Download
Prompt
To download the code, please copy the following command and execute it in the terminal
To ensure that your submitted code identity is correctly recognized by Gitee, please execute the following command.
When using the SSH protocol for the first time to clone or push code, follow the prompts below to complete the SSH configuration.
1 Generate RSA keys.
2 Obtain the content of the RSA public key and configure it in SSH Public Keys
To use SVN on Gitee, please visit the usage guide
When using the HTTPS protocol, the command line will prompt for account and password verification as follows. For security reasons, Gitee recommends configure and use personal access tokens instead of login passwords for cloning, pushing, and other operations.
Username for 'https://gitee.com': userName
Password for 'https://userName@gitee.com': # Private Token
master
Branches (1)
master
stdpython
/
python.lang
/
exception.02.py
stdpython
/
python.lang
/
exception.02.py
exception.02.py 1.52 KB
Copy Edit Raw Blame History
pish7 authored 2025年12月28日 01:28 +08:00 . python
# Python中的异常有 4 个基类,所有其他异常类都继承自这4个基类。
# 当你需要捕获所有异常类别时,通常可以使用这 4 个基‍类。
# くろまる BaseException 所有异常的基类。记住不要直接从这个类继承,因为根据设计它不应被这样使‍用。
# くろまる Exception 所有错误类型异常的基‍类。
# くろまる ArithmeticError 与算术相关的错误类型异常的基‍类。
# くろまる LookupError 与在集合中查找值相关的任何错误类型异常的基‍类。
# BaseException 的直接子类还包括:
# くろまる SystemExit 调用 sys.exit() 时引发
# くろまる KeyboardInterrupt 用户按下键盘组合键以中断正在运行的程序时引发的,例如在类 UNIX 系统中按 Ctrl+C 组合键。
# くろまる GeneratorExit 当生成器遇到 return 语句时,它会引发 GeneratorExit 异常。可以通过捕获该异常来执行一些清理操作,然后再次引发异常以继续生成器的执行。
# くろまる Exception
# 如果第二个参数为 0,则循环再次执行,要求重新输入
# 如果参数匀合法,则结束循环
while True:
x = None
y = None
try:
x = int(input("请输入第一个数:"))
y = int(input("请输入第二个数:"))
z = x / y
print("x / y =", z)
except Exception as e:
print("运行出错", e)
print("请重新开始...")
else:
break
finally:
del x # 应确保这里的 x 和 y 已经定义,通常应该在 try 之前定义这些变量
del y
# print(x)
Loading...
Report
Report success
We will send you the feedback within 2 working days through the letter!
Please fill in the reason for the report carefully. Provide as detailed a description as possible.
Please select a report type
Cancel
Send
误判申诉

此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。

如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。

取消
提交

About

python 语法学习,demo 小示例
Cancel

Releases

No release

Contributors

All

Activities

can not load any more
Edit
About
Homepage
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Python
1
https://gitee.com/aliaodc/stdpython.git
git@gitee.com:aliaodc/stdpython.git
aliaodc
stdpython
stdpython
master
Going to Help Center

Search

Comment
Repository Report
Back to the top
Login prompt
This operation requires login to the code cloud account. Please log in before operating.
Go to login
No account. Register

AltStyle によって変換されたページ (->オリジナル) /