Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
max/min内置函数似乎是贪婪的,即当它不是唯一的情况下,它们将返回第一次出现的情况 。
max
min
>>> x = [('spam', 1), ('egg', 0), ('potato', 1)] >>> max(x, key=lambda v: v[1]) ('spam', 1) >>> max(reversed(x), key=lambda v: v[1]) ('potato', 1)
这是由语言保证的,并且可以依赖于跨平台和以上版本,还是实现细节?