为什么Python的iter()在映射上返回iterkeys()而不是iteritems()?

时间:2022-04-16 20:46:18

It seems like if you want to get the keys of a mapping, you ask for them; otherwise, give me the whole mapping (constituted by a set of key-value pairs). Is there a historical reason for this?

看起来如果你想获得一个映射的键,你就要求它们;否则,给我整个映射(由一组键值对组成)。这有历史原因吗?

1 个解决方案

#1


9  

Check out this thread for a discussion on the reasons behind this behavior (including that Guido likes it, and it's not likely to change).

查看此主题以讨论此行为背后的原因(包括Guido喜欢它,并且它不太可能改变)。

#1


9  

Check out this thread for a discussion on the reasons behind this behavior (including that Guido likes it, and it's not likely to change).

查看此主题以讨论此行为背后的原因(包括Guido喜欢它,并且它不太可能改变)。