鱼C论坛

 找回密码
 立即注册
查看: 1549|回复: 2

[吹水] 后悔

[复制链接]
发表于 2023-8-7 10:21:24 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能^_^

您需要 登录 才可以下载或查看,没有账号?立即注册

x
今天我在小甲鱼的课程上跟着用while循环模拟for循环:

>>> x = [1,1,2,3,5]
>>> _ = iter(x)
>>> while True:
             try:
                        i = _.__next__()
             except StopIteration:
                         break
             print(i,end=' ')

1 1 2 3 5

但第三段代码的第三行我少写了一对括号:

>>> while True:
             try:
                        i = _.__next__
             except StopIteration:
                         break
             print(i,end=' ')

然后,我看到了神奇的一幕:

>>> while True:
             try:
                        i = _.__next__
             except StopIteration:
                         break
             print(i,end=' ')

<method-wrapper '__next__' of list_iterator object at 0x0120B2E0> <method-wrapper '__next__' of list_iterator object at 0x0120B2E0> <method-wrapper '__next__' of list_iterator object at 0x0120B2E0> <method-wrapper '__next__' of list_iterator object at 0x0120B2E0> <method-wrapper '__next__' of list_iterator object at 0x0120B2E0> <method-wrapper '__next__' of list_iterator object at 0x0120B2E0> <method-wrapper '__next__' of list_iterator object at 0x0120B2E0> <method-wrapper '__next__' of list_iterator object at 0x0120B2E0> <method-wrapper '__next__' of list_iterator object at 0x0120B2E0> <method-wrapper '__next__' of list_iterator object at 0x0120B2E0> <method-wrapper '__next__' of list_iterator object at 0x0120B2E0> <method-wrapper '__next__' of list_iterator object at 0x0120B2E0> <method-wrapper '__nex......

我呆了十几秒才反应过来用 Ctrl + C 强制暂停,以至于我的电脑出现了11483行代码!

不怕电脑去世的可以去试试
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复

使用道具 举报

发表于 2023-8-7 10:23:35 | 显示全部楼层
我后悔升级 Windows11
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复 支持 反对

使用道具 举报

发表于 2023-8-24 20:58:29 | 显示全部楼层
没逝啊
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复 支持 反对

使用道具 举报

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

本版积分规则

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

GMT+8, 2024-9-22 17:25

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

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