鱼C论坛

 找回密码
 立即注册
查看: 2310|回复: 1

python第033课课后题

[复制链接]
发表于 2016-12-13 15:55:25 | 显示全部楼层 |阅读模式
1鱼币
try:
    for i in range(3):
        for j in range(3):
            if i == 2:
                raise KeyboardInterrupt
            print(i, j)
except KeyboardInterrupt:
    print('退出啦!')
课后题中的这段我不是很懂,raise KeyboardInterrupt制造一个异常,异常后还执行以下的语句吗,为什么会打印
0 0
0 1
0 2
1 0
1 1
1 2
退出啦!

最佳答案

查看完整内容

因为你已经处理了异常:
小甲鱼最新课程 -> https://ilovefishc.com
回复

使用道具 举报

发表于 2016-12-13 15:55:26 | 显示全部楼层
因为你已经处理了异常:
try:
    #...
except KeyboardInterrupt:
    print('退出啦!')
小甲鱼最新课程 -> https://ilovefishc.com
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

小黑屋|手机版|Archiver|鱼C工作室 ( 粤ICP备18085999号-1 | 粤公网安备 44051102000585号)

GMT+8, 2026-2-24 11:43

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表