def test(level):
if level<5:
raise Exception("没熟没熟")
try:
test(5)
except Exception as e:
print(e)
else:
print("熟了 请吃")
异常捕获,rasie可以改成return
- 写回答
- 好问题 0 提建议
- 关注问题
- 邀请回答
-
1条回答 默认 最新
sinJack 2022-07-02 22:56关注def test(level): if level<5: return "没熟没熟" str=test(5) if str=="没熟没熟": print(str) else: print("熟了 请吃")解决 无用评论 打赏 举报