gpt4 book ai didi

python - 为什么下面的代码表现得如此奇怪? Python3.5 与 Python3.6

转载 作者:太空宇宙 更新时间:2023-11-03 12:52:56 25 4
gpt4 key购买 nike

<分区>

正如标题所说,为什么下面的代码表现得如此奇怪?

a = {
0: 0
}
b = []

for i in a:
del a[i]
a[i + 1] = 0
b.append(i)

print(b)

在Python3.6中打印[0, 1, 2, 3, 4],而在Python3.5中打印[0, 1, 2, 3, 4, 5] , 6, 7]。为什么?

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com